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
|
#!/bin/bash
|
||||||
set -e
|
set -Eeuo pipefail
|
||||||
IFACE=$1
|
IFACE=$1
|
||||||
# vm<vm_id>.<num>
|
|
||||||
|
|
||||||
source /etc/libvirt/hooks/$IFACE
|
source /etc/libvirt/hooks/$IFACE || true
|
||||||
echo CLUSTER=$CLUSTER
|
|
||||||
|
|
||||||
if ! [[ $CLUSTER =~ ^[0-9]+$ ]]; then
|
if ! [[ $CLUSTER =~ ^[0-9]+$ ]]; then
|
||||||
echo "CLUSTER seems not to be valid"
|
echo "CLUSTER seems not to be valid"
|
||||||
exit 10
|
exit 10
|
||||||
fi
|
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}
|
BRIDGE=br${CLUSTER}
|
||||||
VXLAN=vxlan${CLUSTER}
|
VXLAN=vxlan${CLUSTER}
|
||||||
VNI=${CLUSTER}
|
VNI=${CLUSTER}
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -Eeuo pipefail
|
||||||
set -x
|
|
||||||
IFACE=$1
|
IFACE=$1
|
||||||
|
|
||||||
source /etc/libvirt/hooks/$IFACE
|
source /etc/libvirt/hooks/$IFACE || true
|
||||||
echo CLUSTER=$CLUSTER
|
|
||||||
echo IP=$IP
|
: ${PUBLICMAC:=52:54:00:00:00:11}
|
||||||
|
|
||||||
maxprefixv6=64
|
maxprefixv6=64
|
||||||
maxprefixv4=25
|
maxprefixv4=25
|
||||||
|
|
||||||
publicmac=52:54:00:00:00:11
|
|
||||||
|
|
||||||
|
|
||||||
if [ -z $IP ]; then
|
if [ -z $IP ]; then
|
||||||
echo "got nothing back from the API"
|
echo "got nothing back from the API"
|
||||||
exit 10
|
exit 10
|
||||||
|
@ -30,6 +26,7 @@ eui64() {
|
||||||
|
|
||||||
|
|
||||||
ip link set up ${IFACE}
|
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
|
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
|
fi
|
||||||
|
|
||||||
echo "we got IPv6 with prefix ${BASH_REMATCH[0]}"
|
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
|
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"
|
echo "Unable to detect with what prefix I'm working with"
|
||||||
|
|
Loading…
Reference in New Issue