From fb96f1daa8721562a4ed8c1bce7e47e4aa549149 Mon Sep 17 00:00:00 2001 From: toby Date: Thu, 21 Feb 2019 01:02:35 +0000 Subject: [PATCH] adding more resiliancy to the ifup-public script. we want it to maybe fail if it doesn't know what to do with the variable. not just silently continue --- files/qemu-ifup-public | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/files/qemu-ifup-public b/files/qemu-ifup-public index 36e2d27..eea116e 100755 --- a/files/qemu-ifup-public +++ b/files/qemu-ifup-public @@ -11,7 +11,7 @@ maxprefixv4=25 if [ -z $IP ]; then echo "got nothing back from the API" - exit 10 + exit 10 fi eui64() { @@ -45,7 +45,7 @@ for IP in "${IPS[@]}"; do fi echo "we got IPv4 with prefix ${BASH_REMATCH[0]}" - ip route add ${IP} dev ${IFACE} + ip route add ${IP} dev ${IFACE} elif [[ $IP =~ ^2604:bbc0:[0-9,a-f,:]{1,444}/([0-9]{2,3})$ ]]; then ### we got a PIv6 prefix < masprefixv6 @@ -60,9 +60,13 @@ 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 + elif [[ $IP =~ ^\ *$ ]]; then + echo "we just got an empty string. so not gonna do anything. probably due to splitting the comma" + + else echo "Unable to detect with what prefix I'm working with" + exit 10 fi done