]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/ganeti2/templates/instance-debootstrap/hooks/00-dsa-configure-networking.erb
8449f914595c88e240f29cdd6ea1feccb2c1eeed
[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
26 ###########################################
27 fqdn=$(cat $TARGET/etc/hostname)
28 echo ${fqdn%%.*} > $TARGET/etc/hostname
29
30 ###########################################
31 if [ "$NIC_COUNT" -ge 1 ]; then
32   cat > $TARGET/etc/network/interfaces << EOF
33 # /etc/network/interfaces
34
35 auto lo
36 iface lo inet loopback
37
38 EOF
39
40
41 ###########################################
42 ###########################################
43 <% if scope.lookupvar('::cluster').to_s == 'ganeti2.debian.org' -%>
44
45 ###########################################
46 if [ "$NIC_COUNT" -ge 1 ]; then
47   cat >> $TARGET/etc/network/interfaces << EOF
48 auto eth0
49 iface eth0 inet static
50   address ${NIC_0_IP}
51   netmask 255.255.255.0
52   gateway 206.12.19.254
53
54   pre-up /sbin/sysctl -w net.ipv6.conf.\$IFACE.accept_ra=0 || true
55   up   ip addr add 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS/64 dev \$IFACE
56   up   ip r add default via 2607:f8f0:610:4000::1 src 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS dev \$IFACE
57   down ip r del default via 2607:f8f0:610:4000::1 src 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS dev \$IFACE
58   down ip addr del 2607:f8f0:610:4000:6564:0a62:\$IF_ADDRESS/64 dev \$IFACE
59 EOF
60
61 fi
62
63 ###########################################
64 cat > $TARGET/etc/resolv.conf <<EOF
65 # /etc/resolv.conf
66 search debprivate-ubc.debian.org debian.org
67 nameserver 206.12.19.20
68 nameserver 206.12.19.21
69 EOF
70
71 ###########################################
72 ###########################################
73 <% elif scope.lookupvar('::cluster').to_s == 'ganeti-osuosl.debian.org' -%>
74 #
75 ###########################################
76 if [ "$NIC_COUNT" -ge 1 ]; then
77   cat >> $TARGET/etc/network/interfaces << EOF
78 auto eth0
79 iface eth0 inet static
80   address ${NIC_0_IP}
81   netmask 255.255.255.128
82   gateway 140.211.166.1
83
84   pre-up /sbin/sysctl -w net.ipv6.conf.\$IFACE.accept_ra=0 || true
85 EOF
86
87 fi
88
89 ###########################################
90 cat > $TARGET/etc/resolv.conf <<EOF
91 # /etc/resolv.conf
92 search debian.org
93 nameserver 140.211.166.130
94 nameserver 140.211.166.131
95 EOF
96
97 <% else -%>
98
99 cp /etc/resolv.conf $TARGET/etc/resolv.conf
100
101 <% end -%>
102
103
104
105
106 ###########################################
107 if [ "$NIC_COUNT" -ge 2 ]; then
108   cat >> $TARGET/etc/network/interfaces << EOF
109
110 auto eth1
111 iface eth1 inet static
112   address ${NIC_1_IP}
113   netmask 255.255.255.0
114 EOF
115
116 fi
117
118 ###########################################
119 # clean up etc/hosts
120 cat > $TARGET/etc/hosts << EOF
121 127.0.0.1       localhost
122 ${NIC_0_IP} ${fqdn} ${fqdn%%.*}
123
124 # The following lines are desirable for IPv6 capable hosts
125 ::1     ip6-localhost ip6-loopback
126 fe00::0 ip6-localnet
127 ff00::0 ip6-mcastprefix
128 ff02::1 ip6-allnodes
129 ff02::2 ip6-allrouters
130 EOF
131
132 exit 0
133
134 # vim:set syn=sh: