]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/ganeti2/templates/instance-debootstrap/hooks/00-dsa-configure-networking.erb
fe2a281880f6a5979023b179d7b33a52edd58a90
[dsa-puppet.git] / modules / ganeti2 / templates / instance-debootstrap / hooks / 00-dsa-configure-networking.erb
1 #!/bin/bash
2
3 set -e
4
5 if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
6   echo "Missing target directory"
7   exit 1
8 fi
9
10 if [ ! -d "$TARGET/etc/network" ]; then
11   echo "Missing target network directory"
12   exit 1
13 fi
14
15 if [ -z "$NIC_COUNT" ]; then
16   echo "Missing NIC COUNT"
17   exit 1
18 fi
19
20 rm -f $TARGET/etc/udev/rules.d/70-persistent-net.rules
21
22 touch $TARGET/etc/udev/rules.d/75-cd-aliases-generator.rules
23 touch $TARGET/etc/udev/rules.d/75-persistent-net-generator.rules
24
25 if [ "$NIC_COUNT" -ge 1 ]; then
26   cat > $TARGET/etc/network/interfaces << EOF
27 # /etc/network/interfaces
28
29 auto lo
30 iface lo inet loopback
31
32 auto eth0
33 iface eth0 inet static
34   address ${NIC_0_IP}
35   netmask 255.255.255.0
36   gateway 206.12.19.254
37
38   pre-up /sbin/sysctl -w net.ipv6.conf.\$IFACE.accept_ra=0 || true
39   up   ip addr add 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS/64 dev \$IFACE
40   up   ip r add default via 2607:f8f0:610:4000::1 src 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS dev \$IFACE
41   down ip r del default via 2607:f8f0:610:4000::1 src 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS dev \$IFACE
42   down ip addr del 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS/64 dev \$IFACE
43 EOF
44
45 fi
46
47 if [ "$NIC_COUNT" -ge 2 ]; then
48   cat >> $TARGET/etc/network/interfaces << EOF
49
50 auto eth1
51 iface eth1 inet static
52   address ${NIC_1_IP}
53   netmask 255.255.255.0
54 EOF
55
56 fi
57
58 fqdn=$(cat $TARGET/etc/hostname)
59 echo ${fqdn%%.*} > $TARGET/etc/hostname
60
61 cat > $TARGET/etc/resolv.conf <<EOF
62 # /etc/resolv.conf
63 search debprivate-ubc.debian.org debian.org
64 nameserver 206.12.19.20
65 nameserver 206.12.19.21
66 EOF
67
68 # clean up etc/hosts
69 cat > $TARGET/etc/hosts << EOF
70 127.0.0.1       localhost
71
72 # The following lines are desirable for IPv6 capable hosts
73 ::1     ip6-localhost ip6-loopback
74 fe00::0 ip6-localnet
75 ff00::0 ip6-mcastprefix
76 ff02::1 ip6-allnodes
77 ff02::2 ip6-allrouters
78 EOF
79
80 exit 0
81
82 # vim:set syn=sh: