adding more support for ipmigw/mgmtgw interfaces
This commit is contained in:
parent
65b2ecb368
commit
a6e4647a9c
|
@ -21,6 +21,7 @@ case "$1" in
|
||||||
configure)
|
configure)
|
||||||
|
|
||||||
|
|
||||||
|
## START gather all the info from the box and generate the variabels
|
||||||
IFCONFIG="/etc/network/interfaces"
|
IFCONFIG="/etc/network/interfaces"
|
||||||
UDEVCONFIG="/etc/udev/rules.d/70-persistent-net.rules"
|
UDEVCONFIG="/etc/udev/rules.d/70-persistent-net.rules"
|
||||||
FRRCONFIG="/etc/frr/frr.conf.wit"
|
FRRCONFIG="/etc/frr/frr.conf.wit"
|
||||||
|
@ -28,26 +29,32 @@ case "$1" in
|
||||||
SWANCTLCONFIG="/etc/swanctl/conf.d/swanctl-wit.conf.wit"
|
SWANCTLCONFIG="/etc/swanctl/conf.d/swanctl-wit.conf.wit"
|
||||||
|
|
||||||
|
|
||||||
## START gather all the info from the box and generate the variabels
|
|
||||||
|
|
||||||
dig_txt() {
|
dig_txt() {
|
||||||
TMPDIG=$(dig txt +short $1)
|
TMPDIG=$(dig txt +short $1)
|
||||||
[ -z $TMPDIG ] && exit 2
|
[ -z ${TMPDIG} ] && exit 2
|
||||||
TMPDIG=${TMPDIG//\//\\\/}
|
TMPDIG=${TMPDIG//\//\\\/}
|
||||||
TMPDIG=${TMPDIG//\"/} #" fix the god damn syntax highlighter
|
TMPDIG=${TMPDIG//\"/} #" fix the god damn syntax highlighter
|
||||||
echo ${TMPDIG}
|
echo ${TMPDIG}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dig_a {
|
||||||
|
TMPDIG=$(dig a +short $1)
|
||||||
|
[ -z ${TMPDIG} ] && exit 2
|
||||||
|
echo ${TMPDIG}
|
||||||
|
}
|
||||||
|
|
||||||
LOOPBACKv4=$(dig a +short ${HOSTNAME})
|
dig_aaaa {
|
||||||
LOOPBACKv6=$(dig aaaa +short ${HOSTNAME})
|
TMPDIG=$(dig aaaa +short $1)
|
||||||
|
[ -z ${TMPDIG} ] && exit 2
|
||||||
|
echo ${TMPDIG}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LOOPBACKv4=$(dig_a ${HOSTNAME})
|
||||||
|
LOOPBACKv6=$(dig_aaaa ${HOSTNAME})
|
||||||
NODEASN=$(dig_txt asn.${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
|
## END variables
|
||||||
|
|
||||||
|
@ -208,6 +215,21 @@ case "$1" in
|
||||||
EOF
|
EOF
|
||||||
fi
|
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
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue