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:
parent
39d7830086
commit
2af76bb4e8
|
@ -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}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue