Ubuntu Pastebin

Paste from smoser at Mon, 20 Mar 2017 19:19:58 +0000

Download as text
 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
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
name=$1
[ -n "$name" ] || { echo "must give name"; exit 1; }
set -ex
lxc init ubuntu-daily:zesty $name
lxc network attach lxdbr0 $name eth1
# pastebinit `which lxc-chroot`
# http://paste.ubuntu.com/24198752/

# lxc-chroot has access to /var/lib/cloud/seed/nocloud-net/
# despite https://github.com/lxc/lxd/issues/3088 because it does
# a 'start', which will get those things rendered.
# the start just doesn't actually run an init.
mode=${2:-bond}
p=/var/lib/cloud/seed/nocloud-net/network-config
set +x
lxc-chroot "$name" sh -c '
#!/bin/sh
fname="$1"
mode="$2"
scn="/sys/class/net/"
read addr0 < $scn/eth0/address
read addr1 < $scn/eth1/address
if [ "$mode" = "bond" ]; then
cat > "$fname" <<EOF
version: 1
config:
  - type: physical
    name: iface0
    mac_address: $addr0
  - type: physical
    name: iface1
    mac_address: $addr1
  - type: bond
    name: bond0
    bond_interfaces: [iface0, iface1]
    params:
      bond-mode: active-backup
    subnets:
      - type: dhcp
        control: auto
EOF
else
cat > "$fname" <<EOF
version: 1
config:
  - type: physical
    name: eth1
    mac_address: $addr0
    subnets:
      - type: dhcp
        control: auto
  - type: physical
    name: eth2
    mac_address: $addr1
    subnets:
      - type: dhcp
        control: auto
EOF
fi
cat "$fname"
' -- "$p" "$mode"
lxc start "$name"
Download as text