diff --git a/files/qemu-ifup b/files/qemu-ifup index f121df7..898674f 100755 --- a/files/qemu-ifup +++ b/files/qemu-ifup @@ -1,17 +1,15 @@ #!/bin/bash -set -e +set -Eeuo pipefail IFACE=$1 -# vm. -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} diff --git a/files/qemu-ifup-public b/files/qemu-ifup-public index 527868e..6b92066 100755 --- a/files/qemu-ifup-public +++ b/files/qemu-ifup-public @@ -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"