qemu-ifup/public scritps, replaced dig loopback lookup with ip, for more stability and better all round support for outside of libvirt

This commit is contained in:
toby 2019-01-29 18:51:02 +00:00
parent 39d7830086
commit 2af76bb4e8
2 changed files with 9 additions and 14 deletions

View File

@ -1,17 +1,15 @@
#!/bin/bash
set -e
set -Eeuo pipefail
IFACE=$1
# vm<vm_id>.<num>
source /etc/libvirt/hooks/$IFACE
echo CLUSTER=$CLUSTER
source /etc/libvirt/hooks/$IFACE || true
if ! [[ $CLUSTER =~ ^[0-9]+$ ]]; then
echo "CLUSTER seems not to be valid"
exit 10
fi
LOOPBACKIP=$(dig a +short $HOSTNAME)
LOOPBACKIP=$(ip -4 addr show dev lo | grep -Po 'inet \K[\d.]+' | grep -v "^127.0.0.1$")
BRIDGE=br${CLUSTER}
VXLAN=vxlan${CLUSTER}
VNI=${CLUSTER}

View File

@ -1,18 +1,14 @@
#!/bin/bash
set -e
set -x
set -Eeuo pipefail
IFACE=$1
source /etc/libvirt/hooks/$IFACE
echo CLUSTER=$CLUSTER
echo IP=$IP
source /etc/libvirt/hooks/$IFACE || true
: ${PUBLICMAC:=52:54:00:00:00:11}
maxprefixv6=64
maxprefixv4=25
publicmac=52:54:00:00:00:11
if [ -z $IP ]; then
echo "got nothing back from the API"
exit 10
@ -30,6 +26,7 @@ eui64() {
ip link set up ${IFACE}
ip addr add fe80::1/64 dev ${IFACE}
arp -i ${IFACE} -Ds 169.254.0.1 ${IFACE} netmask 255.255.255.255 pub
@ -65,7 +62,7 @@ for IP in "${IPS[@]}"; do
fi
echo "we got IPv6 with prefix ${BASH_REMATCH[0]}"
ip route add ${IP} dev ${IFACE} via $(eui64 $publicmac)
ip route add ${IP} dev ${IFACE} via $(eui64 $PUBLICMAC)
else ### don't know what we have but something we can't work with
echo "Unable to detect with what prefix I'm working with"