Add install guide converted to rst form https://wiki.opnfv.org/joid/b_installguide?do=
[joid.git] / ci / trusty / ubuntu-nodes-controller / lxc / add-more-interface
1 #!/bin/bash
2
3 set -e
4 set -u
5
6 cat <<EOF >> "$LXC_CONFIG_FILE"
7
8 ## added by juju charm
9 lxc.network.type = veth
10 lxc.network.flags = up
11 lxc.network.link = brData
12 lxc.network.name = eth1
13 lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')
14
15 lxc.network.type = veth
16 lxc.network.flags = up
17 lxc.network.link = brPublic
18 lxc.network.name = eth2
19 lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')
20 EOF
21
22 USERDATA="$LXC_ROOTFS_PATH/var/lib/cloud/seed/nocloud-net/user-data"
23
24 additional_interfaces="
25 - |
26   cat <<EOF >> /etc/network/interfaces.d/additional-interfaces
27   ## added by juju charm
28   ## those interfaces will be brought up by the upstart job as /etc/init/additional-interfaces.conf
29   ## LP: #1483932
30   auto eth1
31   iface eth1 inet dhcp
32
33   auto eth2
34   iface eth2 inet dhcp
35   EOF
36 - machine_agent=\$(hostname | sed -e 's/^juju-/jujud-/')
37 - |
38   cat <<EOF > /etc/init/additional-interfaces.conf
39   ## added by juju charm
40   ## LP: #1483932
41   start on started \${machine_agent}
42
43   script
44     sleep 10
45     ifup -a -i /etc/network/interfaces.d/additional-interfaces
46   end script
47   EOF
48 "
49 additional_interfaces=$(echo "$additional_interfaces" | sed -e 's/$/\\n/' | tr -d '\n')
50
51 sed -i.orig -e "s@^runcmd:@\0$additional_interfaces@" \
52     "$USERDATA"