5 # change the password because this script is run on a passwordless cloud-image
6 echo 'ubuntu:opnfv' | chpasswd
10 echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/head
13 # Wait for a floating IP
14 # as a workaround to NAT breakage
17 # Variables to be filled in with python
20 # directly access the instance from the external net without NAT
23 if [[ $(getent hosts | awk '{print $2}') != *"$(cat /etc/hostname | awk '{print $1}')"* ]]
25 echo "127.0.1.1 $(cat /etc/hostname | awk '{print $1}')" | tee -a /etc/hosts
29 for net_int in $(netstat -ia | awk 'NR>2{print $1}');
31 if [ -z "$(ifconfig | grep $net_int)" ]
37 if [ -z "$quagga_int" ]
39 echo 'No available network interface'
42 ip link set $quagga_int up
43 ip addr add $OWN_IP/$EXT_NET_MASK dev $quagga_int
45 ZEBRA_CONFIG_LOCATION="/etc/quagga/zebra.conf"
46 DAEMONS_FILE_LOCATION="/etc/quagga/daemons"
47 BGPD_CONFIG_LOCATION="/etc/quagga/bgpd.conf"
48 BGPD_LOG_FILE="/var/log/bgpd.log"
50 DEBIAN_FRONTEND=noninteractive apt-get update
51 DEBIAN_FRONTEND=noninteractive apt-get install quagga -y
54 chown quagga:quagga $BGPD_LOG_FILE
56 chown quagga:quagga $DAEMONS_FILE_LOCATION
57 cat <<CATEOF > $DAEMONS_FILE_LOCATION
68 touch $ZEBRA_CONFIG_LOCATION
69 chown quagga:quagga $ZEBRA_CONFIG_LOCATION
71 cat <<CATEOF > $BGPD_CONFIG_LOCATION
78 bgp router-id ${OWN_IP}
79 neighbor ${NEIGHBOR_IP} remote-as 100
80 no neighbor ${NEIGHBOR_IP} activate
82 address-family vpnv4 unicast
83 neighbor ${NEIGHBOR_IP} activate
91 log file ${BGPD_LOG_FILE}
94 chown quagga:quagga $BGPD_CONFIG_LOCATION
95 service quagga restart