summaryrefslogtreecommitdiffstats
path: root/ci/trusty/ubuntu-nodes-controller/lxc/add-more-interface
blob: c9bca9fd71f06b46c21297601301dff9ee00669b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

set -e
set -u

cat <<EOF >> "$LXC_CONFIG_FILE"

## added by juju charm
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = brData
lxc.network.name = eth1
lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = brPublic
lxc.network.name = eth2
lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')
EOF

USERDATA="$LXC_ROOTFS_PATH/var/lib/cloud/seed/nocloud-net/user-data"

additional_interfaces="
- |
  cat <<EOF >> /etc/network/interfaces.d/additional-interfaces
  ## added by juju charm
  ## those interfaces will be brought up by the upstart job as /etc/init/additional-interfaces.conf
  ## LP: #1483932
  auto eth1
  iface eth1 inet dhcp

  auto eth2
  iface eth2 inet dhcp
  EOF
- machine_agent=\$(hostname | sed -e 's/^juju-/jujud-/')
- |
  cat <<EOF > /etc/init/additional-interfaces.conf
  ## added by juju charm
  ## LP: #1483932
  start on started \${machine_agent}

  script
    sleep 10
    ifup -a -i /etc/network/interfaces.d/additional-interfaces
  end script
  EOF
"
additional_interfaces=$(echo "$additional_interfaces" | sed -e 's/$/\\n/' | tr -d '\n')

sed -i.orig -e "s@^runcmd:@\0$additional_interfaces@" \
    "$USERDATA"