updates for t11 and fsf
[automated-distro-installer] / fai / config / scripts / FSF / 11-iank
1 #!/bin/bash -x
2
3 set -eE -o pipefail
4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
5
6 if [[ $EUID != 0 ]]; then
7 echo "$0: error: expected to be root."
8 exit 1
9 fi
10
11
12 sed 's/^/root:/' $FAI/distro-install-common/shadow/community0p | $ROOTCMD chpasswd -e
13
14 # todo, need to set static ip here
15 if ifclass demohost; then
16 cat > $target/etc/network/interfaces <<EOF
17 # generated by FAI
18 auto lo eth0
19 iface lo inet loopback
20 iface eth0 inet dhcp
21 iface eth0 inet6 auto
22
23 source-directory /etc/network/interfaces.d
24 EOF
25 else
26 ip6=$(getent ahosts $HOSTNAME |grep ^2001.*RAW| sed 's/ .*//' ||:)
27 gateway6=2001:470:142::1
28
29 # todo: this needs adjustment per machine
30 internal_ip=10.0.0.25/16
31
32 if ip l show dev bond0 &>/dev/null; then
33 cat >$target/etc/network/interfaces <<EOF
34 auto lo
35 iface lo inet loopback
36
37 auto eth0
38 allow-bond eth0
39 iface eth0 inet manual
40 bond-master bond0
41
42 auto eth1
43 allow-bond eth1
44 iface eth1 inet manual
45 bond-master bond0
46
47 auto bond0
48 iface bond0 inet static
49 bond-slaves none
50 bond-mode 0
51 bond-miimon 100
52 address $internal_ip
53 pre-up ip link add link bond0 name macvtap-bond0 type macvtap mode bridge
54 # no iptables files exist yet
55 # post-up iptables-restore < /etc/default/iptables ; ip6tables-restore < /etc/default/ip6tables || :
56
57 auto macvtap-bond0
58 iface macvtap-bond0 inet static
59 address $CIDR
60 gateway $GATEWAYS
61 post-up ip a add $internal_ip broadcast 10.0.255.255 dev macvtap-bond0
62
63 EOF
64
65 # I'm not sure ipv6 works well with the macvtap stuff. todo: research.
66 # anyways, other kvm hosts dont have it enabled.
67 if false && [[ $ip6 ]]; then
68 cat >>$target/etc/network/interfaces <<EOF
69 iface bond0 inet6 static
70 pre-up echo 0 > /proc/sys/net/ipv6/conf/bond0/accept_dad
71 address $ip6
72 netmask 48
73 gateway $gateway6
74 EOF
75 fi
76
77 else
78 cat > $target/etc/network/interfaces <<EOF
79 auto lo
80 iface lo inet loopback
81
82 auto eth0
83 iface eth0 inet static
84 address $CIDR
85 gateway $GATEWAYS
86 EOF
87
88 if [[ $ip6 ]]; then
89 cat >>$target/etc/network/interfaces <<EOF
90 iface eth0 inet6 static
91 pre-up echo 0 > /proc/sys/net/ipv6/conf/eth0/accept_dad
92 address $ip6
93 netmask 48
94 gateway $gateway6
95 EOF
96 fi
97 fi
98 fi
99
100 # previously had an else condition after
101 #elif ifclass VM || ifclass LINODE; then
102 # iface $NIC1 inet manual
103 # iface br0 inet dhcp
104 # bridge_ports $NIC1
105 # bridge_stp off
106 # bridge_maxwait 0
107 # however, on t9, on startup, br0, became
108 # rename1 and didn't come up. i dunno why,
109 # but the bridge is for vms that I rarely use,
110 # so not bothering to figure it out.
111
112
113 ##### end network setup #####
114
115 # note: systemd-resolved + ifupdown causes networking.service to fail in t11,
116 # https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1907878
117 systemctl disable systemd-resolved
118 # rm first to remove any symlink
119 rm -f $target/etc/resolv.conf
120
121 if ifclass demohost || [[ $GATEWAYS != 209.51.188.* ]]; then
122 cat >$target/etc/resolv.conf <<'EOF'
123 nameserver 8.8.8.8
124 EOF
125 else
126 cat >$target/etc/resolv.conf <<'EOF'
127 domain fsf.org
128 search fsf.org
129 nameserver 209.51.188.16
130 nameserver 209.51.188.27
131 EOF
132 fi