adding more support for ipmigw/mgmtgw interfaces

This commit is contained in:
toby 2018-10-31 21:02:57 +01:00
parent 65b2ecb368
commit a6e4647a9c
1 changed files with 31 additions and 9 deletions

View File

@ -21,6 +21,7 @@ case "$1" in
configure)
## START gather all the info from the box and generate the variabels
IFCONFIG="/etc/network/interfaces"
UDEVCONFIG="/etc/udev/rules.d/70-persistent-net.rules"
FRRCONFIG="/etc/frr/frr.conf.wit"
@ -28,26 +29,32 @@ case "$1" in
SWANCTLCONFIG="/etc/swanctl/conf.d/swanctl-wit.conf.wit"
## START gather all the info from the box and generate the variabels
dig_txt() {
TMPDIG=$(dig txt +short $1)
[ -z $TMPDIG ] && exit 2
[ -z ${TMPDIG} ] && exit 2
TMPDIG=${TMPDIG//\//\\\/}
TMPDIG=${TMPDIG//\"/} #" fix the god damn syntax highlighter
echo ${TMPDIG}
}
dig_a {
TMPDIG=$(dig a +short $1)
[ -z ${TMPDIG} ] && exit 2
echo ${TMPDIG}
}
LOOPBACKv4=$(dig a +short ${HOSTNAME})
LOOPBACKv6=$(dig aaaa +short ${HOSTNAME})
dig_aaaa {
TMPDIG=$(dig aaaa +short $1)
[ -z ${TMPDIG} ] && exit 2
echo ${TMPDIG}
}
LOOPBACKv4=$(dig_a ${HOSTNAME})
LOOPBACKv6=$(dig_aaaa ${HOSTNAME})
NODEASN=$(dig_txt asn.${HOSTNAME})
if [ -z $LOOPBACKv4 ] || [ -z $LOOPBACKv6 ] || [ -z $NODEASN ]; then
echo "unable to find my LOOPBACK IP and/or ASN: $LOOPBACKv4/$LOOPBACKv6/$NODEASN"
exit 2
fi
## END variables
@ -208,6 +215,21 @@ case "$1" in
EOF
fi
if [[ $ifname = mgmtgw1 ]] || [[ $ifname = ipmigw1 ]]; then ## only 1 mgmt interface supported for now
ipv4=$(dig_txt ipv4.$if.${HOSTNAME})
cat <<-EOF >>$IFCONFIG
auto ${if}
iface ${if} inet static
address $ipv4
EOF
fi
done
done