Merge "Fix typo in quagga script and call to glance" 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 # Wait for a floating IP
9 # as a workaround to NAT breakage
10 sleep 20
11
12 # Variables to be filled in with python
13 NEIGHBOR_IP=%s
14 OWN_IP=%s
15 # directly access the instance from the external net without NAT
16 EXT_NET_MASK=%s
17
18 ip link set ens7 up
19 ip addr add $OWN_IP/$EXT_NET_MASK dev ens7
20
21 ZEBRA_CONFIG_LOCATION="/etc/quagga/zebra.conf"
22 DAEMONS_FILE_LOCATION="/etc/quagga/daemons"
23 BGPD_CONFIG_LOCATION="/etc/quagga/bgpd.conf"
24 BGPD_LOG_FILE="/var/log/bgpd.log"
25
26 DEBIAN_FRONTEND=noninteractive apt-get update
27 DEBIAN_FRONTEND=noninteractive apt-get install quagga -y
28
29 touch $BGPD_LOG_FILE
30 chown quagga:quagga $BGPD_LOG_FILE
31
32 chown quagga:quagga $DAEMONS_FILE_LOCATION
33 cat <<CATEOF > $DAEMONS_FILE_LOCATION
34 zebra=yes
35 bgpd=yes
36 ospfd=no
37 ospf6d=no
38 ripd=no
39 ripngd=no
40 isisd=no
41 babeld=no
42 CATEOF
43
44 touch $ZEBRA_CONFIG_LOCATION
45 chown quagga:quagga $ZEBRA_CONFIG_LOCATION
46
47 cat <<CATEOF > $BGPD_CONFIG_LOCATION
48 ! -*- bgp -*-
49
50 hostname bgpd
51 password sdncbgpc
52
53 router bgp 200
54  bgp router-id ${OWN_IP}
55  neighbor ${NEIGHBOR_IP} remote-as 100
56  no neighbor ${NEIGHBOR_IP} activate
57 !
58  address-family vpnv4 unicast
59  neighbor ${NEIGHBOR_IP} activate
60  exit-address-family
61 !
62 line vty
63  exec-timeout 0 0
64 !
65 debug bgp events
66 debug bgp  updates
67 log file ${BGPD_LOG_FILE}
68 end
69 CATEOF
70 chown quagga:quagga $BGPD_CONFIG_LOCATION
71
72 pgrep bgpd
73 pgrep zebra