5 # change the password because this script is run on a passwordless cloud-image
6 echo 'ubuntu:opnfv' | chpasswd
8 # Wait for a floating IP
9 # as a workaround to NAT breakage
12 # Variables to be filled in with python
15 # directly access the instance from the external net without NAT
18 if [[ $(getent hosts | awk '{print $2}') != *"$(cat /etc/hostname | awk '{print $1}')"* ]]
20 echo "127.0.1.1 $(cat /etc/hostname | awk '{print $1}')" | tee -a /etc/hosts
24 for net_int in $(netstat -ia | awk 'NR>2{print $1}');
26 if [ -z "$(ifconfig | grep $net_int)" ]
32 if [ -z "$quagga_int" ]
34 echo 'No available network interface'
37 ip link set $quagga_int up
38 ip addr add $OWN_IP/$EXT_NET_MASK dev $quagga_int
40 ZEBRA_CONFIG_LOCATION="/etc/quagga/zebra.conf"
41 DAEMONS_FILE_LOCATION="/etc/quagga/daemons"
42 BGPD_CONFIG_LOCATION="/etc/quagga/bgpd.conf"
43 BGPD_LOG_FILE="/var/log/bgpd.log"
45 # Quagga is already installed to run as well in setups without inet
47 # echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/head
49 # DEBIAN_FRONTEND=noninteractive apt-get update
50 # DEBIAN_FRONTEND=noninteractive apt-get install quagga -y
53 chown quagga:quagga $BGPD_LOG_FILE
55 chown quagga:quagga $DAEMONS_FILE_LOCATION
56 cat <<CATEOF > $DAEMONS_FILE_LOCATION
67 touch $ZEBRA_CONFIG_LOCATION
68 chown quagga:quagga $ZEBRA_CONFIG_LOCATION
70 cat <<CATEOF > $BGPD_CONFIG_LOCATION
77 bgp router-id ${OWN_IP}
78 neighbor ${NEIGHBOR_IP} remote-as 100
79 no neighbor ${NEIGHBOR_IP} activate
81 address-family vpnv4 unicast
82 neighbor ${NEIGHBOR_IP} activate
90 log file ${BGPD_LOG_FILE}
93 chown quagga:quagga $BGPD_CONFIG_LOCATION
94 service quagga restart