8983387b7487bda691022c5202f9182f58adce2e
[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
16 ZEBRA_CONFIG_LOCATION="/etc/quagga/zebra.conf"
17 DAEMONS_FILE_LOCATION="/etc/quagga/daemons"
18 BGPD_CONFIG_LOCATION="/etc/quagga/bgpd.conf"
19 BGPD_LOG_FILE="/var/log/bgpd.log"
20
21 DEBIAN_FONTEND=noninteractive apt-get update
22 DEBIAN_FRONTEND=noninteractive apt-get install quagga -y
23
24 touch $BGPD_LOG_FILE
25 chown quagga:quagga $BGPD_LOG_FILE
26
27 chown quagga:quagga $DAEMONS_FILE_LOCATION
28 cat <<CATEOF > $DAEMONS_FILE_LOCATION
29 zebra=yes
30 bgpd=yes
31 ospfd=no
32 ospf6d=no
33 ripd=no
34 ripngd=no
35 isisd=no
36 babeld=no
37 CATEOF
38
39 touch $ZEBRA_CONFIG_LOCATION
40 chown quagga:quagga $ZEBRA_CONFIG_LOCATION
41
42 cat <<CATEOF > $BGPD_CONFIG_LOCATION
43 ! -*- bgp -*-
44
45 hostname bgpd
46 password sdncbgpc
47
48 router bgp 200
49  bgp router-id ${OWN_IP}
50  neighbor ${NEIGHBOR_IP} remote-as 100
51  no neighbor ${NEIGHBOR_IP} activate
52 !
53  address-family vpnv4 unicast
54  neighbor ${NEIGHBOR_IP} activate
55  exit-address-family
56 !
57 line vty
58  exec-timeout 0 0
59 !
60 debug bgp events
61 debug bgp  updates
62 log file ${BGPD_LOG_FILE}
63 end
64 CATEOF
65 chown quagga:quagga $BGPD_CONFIG_LOCATION
66
67 pgrep bgpd
68 pgrep zebra