Check for errors by default in scripts
[icn.git] / deploy / metal3-vm / ubuntu_bridge_network_configuration.sh
1 #!/usr/bin/env bash
2 set -eux -o pipefail
3
4 # shellcheck disable=SC1091
5 source lib/logging.sh
6 # shellcheck disable=SC1091
7 source lib/common.sh
8
9 if [ "$MANAGE_PRO_BRIDGE" == "y" ]; then
10      # Adding an IP address in the libvirt definition for this network results in
11      # dnsmasq being run, we don't want that as we have our own dnsmasq, so set
12      # the IP address here
13      sudo brctl addbr provisioning
14      # sudo ifconfig provisioning 172.22.0.1 netmask 255.255.255.0 up
15      # Use ip command. ifconfig commands are deprecated now.
16      sudo ip addr add dev provisioning 172.22.0.1/24
17      sudo ip link set provisioning up
18
19      # Need to pass the provision interface for bare metal
20      if [ "$PRO_IF" ]; then
21        sudo brctl addif provisioning "$PRO_IF"
22      fi
23  fi
24
25  if [ "$MANAGE_INT_BRIDGE" == "y" ]; then
26      # Create the baremetal bridge
27      if ! [[  $(ip a show baremetal) ]]; then
28        sudo brctl addbr baremetal
29        # sudo ifconfig baremetal 192.168.111.1 netmask 255.255.255.0 up
30        # Use ip command. ifconfig commands are deprecated now.
31        sudo ip addr add dev baremetal 192.168.111.1/24
32        sudo ip link set baremetal up
33      fi
34
35      # Add the internal interface to it if requests, this may also be the interface providing
36      # external access so we need to make sure we maintain dhcp config if its available
37      if [ "$INT_IF" ]; then
38        sudo brctl addif "$INT_IF"
39      fi
40  fi
41
42  # restart the libvirt network so it applies an ip to the bridge
43  if [ "$MANAGE_BR_BRIDGE" == "y" ] ; then
44      sudo virsh net-destroy baremetal
45      sudo virsh net-start baremetal
46      if [ "$INT_IF" ]; then #Need to bring UP the NIC after destroying the libvirt network
47          sudo ifup "$INT_IF"
48      fi
49  fi