Merge "DNS fix for testcase 3" into stable/danube
[sdnvpn.git] / sdnvpn / artifacts / quagga_setup.sh
1 #! /bin/bash
2
3 set -xe
4
5 # change the password because this script is run on a passwordless cloud-image
6 echo 'ubuntu:opnfv' | chpasswd
7
8 # dns fix
9
10 echo "8.8.8.8" > /etc/resolvconf/resolv.conf.d/head
11 resolvconf -u
12
13 # Wait for a floating IP
14 # as a workaround to NAT breakage
15 sleep 20
16
17 # Variables to be filled in with python
18 NEIGHBOR_IP=%s
19 OWN_IP=%s
20 # directly access the instance from the external net without NAT
21 EXT_NET_MASK=%s
22
23 ip link set ens7 up
24 ip addr add $OWN_IP/$EXT_NET_MASK dev ens7
25
26 ZEBRA_CONFIG_LOCATION="/etc/quagga/zebra.conf"
27 DAEMONS_FILE_LOCATION="/etc/quagga/daemons"
28 BGPD_CONFIG_LOCATION="/etc/quagga/bgpd.conf"
29 BGPD_LOG_FILE="/var/log/bgpd.log"
30
31 DEBIAN_FRONTEND=noninteractive apt-get update
32 DEBIAN_FRONTEND=noninteractive apt-get install quagga -y
33
34 touch $BGPD_LOG_FILE
35 chown quagga:quagga $BGPD_LOG_FILE
36
37 chown quagga:quagga $DAEMONS_FILE_LOCATION
38 cat <<CATEOF > $DAEMONS_FILE_LOCATION
39 zebra=yes
40 bgpd=yes
41 ospfd=no
42 ospf6d=no
43 ripd=no
44 ripngd=no
45 isisd=no
46 babeld=no
47 CATEOF
48
49 touch $ZEBRA_CONFIG_LOCATION
50 chown quagga:quagga $ZEBRA_CONFIG_LOCATION
51
52 cat <<CATEOF > $BGPD_CONFIG_LOCATION
53 ! -*- bgp -*-
54
55 hostname bgpd
56 password sdncbgpc
57
58 router bgp 200
59  bgp router-id ${OWN_IP}
60  neighbor ${NEIGHBOR_IP} remote-as 100
61  no neighbor ${NEIGHBOR_IP} activate
62 !
63  address-family vpnv4 unicast
64  neighbor ${NEIGHBOR_IP} activate
65  exit-address-family
66 !
67 line vty
68  exec-timeout 0 0
69 !
70 debug bgp events
71 debug bgp  updates
72 log file ${BGPD_LOG_FILE}
73 end
74 CATEOF
75 chown quagga:quagga $BGPD_CONFIG_LOCATION
76 service quagga restart
77 pgrep bgpd
78 pgrep zebra