summaryrefslogtreecommitdiffstats
path: root/sdnvpn/artifacts/quagga_setup.sh
diff options
context:
space:
mode:
Diffstat (limited to 'sdnvpn/artifacts/quagga_setup.sh')
-rw-r--r--sdnvpn/artifacts/quagga_setup.sh23
1 files changed, 21 insertions, 2 deletions
diff --git a/sdnvpn/artifacts/quagga_setup.sh b/sdnvpn/artifacts/quagga_setup.sh
index 96d7374..6e61d9a 100644
--- a/sdnvpn/artifacts/quagga_setup.sh
+++ b/sdnvpn/artifacts/quagga_setup.sh
@@ -20,8 +20,27 @@ OWN_IP=%s
# directly access the instance from the external net without NAT
EXT_NET_MASK=%s
-ip link set ens7 up
-ip addr add $OWN_IP/$EXT_NET_MASK dev ens7
+if [[ $(getent hosts | awk '{print $2}') != *"$(cat /etc/hostname | awk '{print $1}')"* ]]
+then
+echo "127.0.1.1 $(cat /etc/hostname | awk '{print $1}')" | tee -a /etc/hosts
+fi
+
+quagga_int=''
+for net_int in $(netstat -ia | awk 'NR>2{print $1}');
+do
+if [ -z "$(ifconfig | grep $net_int)" ]
+then
+quagga_int=$net_int
+break
+fi
+done
+if [ -z "$quagga_int" ]
+then
+echo 'No available network interface'
+fi
+
+ip link set $quagga_int up
+ip addr add $OWN_IP/$EXT_NET_MASK dev $quagga_int
ZEBRA_CONFIG_LOCATION="/etc/quagga/zebra.conf"
DAEMONS_FILE_LOCATION="/etc/quagga/daemons"