fixies for fsf special_disk partitioning
[automated-distro-installer] / fai / config / scripts / FSF / 11-iank
1 #!/bin/bash -x
2 # This file is part of Ian Kelling's automated-distro-installer
3 # Copyright (C) 2024 Ian Kelling
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 set -eE -o pipefail
20 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
21
22 if [[ $EUID != 0 ]]; then
23 echo "$0: error: expected to be root."
24 exit 1
25 fi
26
27
28 sed 's/^/root:/' $FAI/distro-install-common/shadow/community0p | $ROOTCMD chpasswd -e
29
30 # todo, need to set static ip here
31 if ifclass demohost; then
32 cat > $target/etc/network/interfaces <<EOF
33 # generated by FAI
34 auto lo eth0
35 iface lo inet loopback
36 iface eth0 inet dhcp
37 iface eth0 inet6 auto
38
39 source-directory /etc/network/interfaces.d
40 EOF
41 else
42 ip6=$(getent ahosts $HOSTNAME |grep ^2001.*RAW| sed 's/ .*//' ||:)
43 gateway6=2001:470:142::1
44
45 # todo: this needs adjustment per machine
46 internal_ip=10.0.0.25/16
47
48 if ip l show dev bond0 &>/dev/null; then
49 cat >$target/etc/network/interfaces <<EOF
50 auto lo
51 iface lo inet loopback
52
53 auto eth0
54 allow-bond eth0
55 iface eth0 inet manual
56 bond-master bond0
57
58 auto eth1
59 allow-bond eth1
60 iface eth1 inet manual
61 bond-master bond0
62
63 auto bond0
64 iface bond0 inet static
65 bond-slaves none
66 bond-mode 0
67 bond-miimon 100
68 address $internal_ip
69 pre-up ip link add link bond0 name macvtap-bond0 type macvtap mode bridge
70 # no iptables files exist yet
71 # post-up iptables-restore < /etc/default/iptables ; ip6tables-restore < /etc/default/ip6tables || :
72
73 auto macvtap-bond0
74 iface macvtap-bond0 inet static
75 address $CIDR
76 gateway $GATEWAYS
77 post-up ip a add $internal_ip broadcast 10.0.255.255 dev macvtap-bond0
78
79 EOF
80
81 # I'm not sure ipv6 works well with the macvtap stuff. todo: research.
82 # anyways, other kvm hosts dont have it enabled.
83 if false && [[ $ip6 ]]; then
84 cat >>$target/etc/network/interfaces <<EOF
85 iface bond0 inet6 static
86 pre-up echo 0 > /proc/sys/net/ipv6/conf/bond0/accept_dad
87 address $ip6
88 netmask 48
89 gateway $gateway6
90 EOF
91 fi
92
93 else
94 cat > $target/etc/network/interfaces <<EOF
95 auto lo
96 iface lo inet loopback
97
98 auto eth0
99 iface eth0 inet static
100 address $CIDR
101 gateway $GATEWAYS
102 EOF
103
104 if [[ $ip6 ]]; then
105 cat >>$target/etc/network/interfaces <<EOF
106 iface eth0 inet6 static
107 pre-up echo 0 > /proc/sys/net/ipv6/conf/eth0/accept_dad
108 address $ip6
109 netmask 48
110 gateway $gateway6
111 EOF
112 fi
113 fi
114 fi
115
116 # previously had an else condition after
117 #elif ifclass VM || ifclass LINODE; then
118 # iface $NIC1 inet manual
119 # iface br0 inet dhcp
120 # bridge_ports $NIC1
121 # bridge_stp off
122 # bridge_maxwait 0
123 # however, on t9, on startup, br0, became
124 # rename1 and didn't come up. i dunno why,
125 # but the bridge is for vms that I rarely use,
126 # so not bothering to figure it out.
127
128
129 ##### end network setup #####
130
131 # note: systemd-resolved + ifupdown causes networking.service to fail in t11,
132 # https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1907878
133
134 # This does an exit 1 with no output. very not nice of systemd to give
135 # us no information on error. However, when i ran the command on a
136 # normal t11 system, it output that it removed 2 files, so hopefully
137 # doing that will be equivalent.
138 #
139 #$ROOTCMD systemctl disable systemd-resolved
140
141 rm -f $target/etc/systemd/system/multi-user.target.wants/systemd-resolved.service
142 rm -f $target/etc/systemd/system/dbus-org.freedesktop.resolve1.service.
143
144 # remove any symlink created by systemd-resolved
145 rm -f $target/etc/resolv.conf
146
147 if ifclass demohost || [[ $GATEWAYS != 209.51.188.* ]]; then
148 cat >$target/etc/resolv.conf <<'EOF'
149 nameserver 8.8.8.8
150 EOF
151 else
152 cat >$target/etc/resolv.conf <<'EOF'
153 domain fsf.org
154 search fsf.org
155 nameserver 209.51.188.16
156 nameserver 209.51.188.27
157 EOF
158 fi
159
160 if ifclass ECNE; then
161 cat >$target/etc/os-release <<'EOF'
162 NAME="Trisquel GNU/Linux"
163 VERSION="12.0, Ecne"
164 ID=trisquel
165 ID_LIKE=debian
166 PRETTY_NAME="Trisquel GNU/Linux Ecne (12.0)"
167 VERSION_ID="12.0"
168 VERSION_CODENAME="ecne"
169 UBUNTU_CODENAME="noble"
170 HOME_URL="https://trisquel.info/"
171 SUPPORT_URL="https://trisquel.info/wiki"
172 BUG_REPORT_URL="https://gitlab.trisquel.org/trisquel"
173 PRIVACY_POLICY_URL="https://trisquel.info/legal"
174 EOF
175
176 cat >$target/etc/apt/apt.conf.d/01-vendor-trisquel <<'EOF'
177 Update-Manager::Always-Include-Phased-Updates "True";
178 EOF
179 rm $target/etc/update-motd.d/{00-header,10-help-text,50-motd-news}
180 truncate -s0 $target/var/run/motd.dynamic
181
182 cat >$target/etc/issue <<'EOF'
183 Trisquel GNU/Linux 12.0 \n \l
184 EOF
185 cat >$target/etc/issue.net <<'EOF'
186 Trisquel GNU/Linux 12.0
187 EOF
188
189 cat >$target/etc/lsb-release <<'EOF'
190 DISTRIB_ID=Trisquel
191 DISTRIB_RELEASE=12.0
192 DISTRIB_CODENAME=ecne
193 DISTRIB_DESCRIPTION="Trisquel GNU/Linux 12.0, Ecne"
194 EOF
195 fi