2 # This file is part of Ian Kelling's automated-distro-installer
3 # Copyright (C) 2024 Ian Kelling
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.
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.
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.
20 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
22 if [[ $EUID != 0 ]]; then
23 echo "$0: error: expected to be root."
27 m
() { printf "%s\n" "$*"; "$@"; }
32 # in bullseye, installing systemd-resolved says: Converting
33 # /etc/resolv.conf to a symlink to
34 # /run/systemd/resolve/stub-resolv.conf... which breaks
35 # resolution. This happens to be the first script we install a package
36 # after that. This should do nothing in a fai-wrapper situation.
37 if [[ ! -s $target/etc
/resolv.conf
]]; then
38 m
ls -la $target/etc
/resolv.conf ||
:
39 # Keep the symlink in place, systemd-resolved should change the file
41 mkdir
-p $target/run
/systemd
/resolve
42 if [[ ! -s /etc
/resolv.conf
]] && ! host google.com
; then
43 echo "ERROR: empty resolv.conf & failed dns resolution. exiting 1" >&2
46 cat /etc
/resolv.conf
>$target/etc
/resolv.conf
51 #### misc configurations
52 chroot
$FAI_ROOT bash
<<'EOFOUTER'
54 if getent group systemd-journal >/dev/null; then
55 # makes the journal be saved to disk.
56 mkdir -p /var/log/journal
57 chmod 755 /var/log/journal
59 debconf-set-selections <<EOF
60 kexec-tools kexec-tools/load_kexec boolean false
63 # This used to be pxe-kexec. For some reason pxe-kexec is not in
64 # bookworm. kexec-tools is
65 # something pxe-kexec depended on and might be useful.
66 # todo: figure out why and get it installed.
67 apt-get install -y kexec-tools
69 # this is usefull. Only thing reason I see this being disabled by default is
70 # that a non-root user can disrupt the system, eg cause a reboot.
71 sed -i '$a kernel.sysrq=1
72 /^kernel.sysrq=/d' /etc/sysctl.conf
76 cmdline_extra
="$d16_cmdline $fsf_cmdline_extra"
78 # luks options, see man systemd-cryptsetup-generator
79 # all i know is that with luks.crypttab=no, swap still timed out on boot.
80 # and with rd.luks.crypttab=no, it works.
81 cmdline
="rd.luks.crypttab=no net.ifnames=0 $cmdline_extra"
83 chroot
$FAI_ROOT bash
<<EOF
86 # https://askubuntu.com/questions/33416/how-do-i-disable-the-boot-splash-screen-and-only-show-kernel-and-boot-text-inst
88 sed -ri 's/(^GRUB_CMDLINE_LINUX_DEFAULT=")quiet/\1/;s/^(GRUB_CMDLINE_LINUX_DEFAULT=".*) quiet([ "])/\1\2/' /etc/default/grub
89 sed -ri 's/(^GRUB_CMDLINE_LINUX_DEFAULT=")splash/\1/;s/^(GRUB_CMDLINE_LINUX_DEFAULT=".*) splash([ "])/\1\2/' /etc/default/grub
91 for arg in $cmdline; do
92 if ! grep "^GRUB_CMDLINE_LINUX_DEFAULT=.*[\" ]\${arg//./\\.}[\" ]" /etc/default/grub; then
93 sed -ri "s/^GRUB_CMDLINE_LINUX_DEFAULT=\"(.*)/GRUB_CMDLINE_LINUX_DEFAULT=\"\$arg \1/" /etc/default/grub
97 if grep -qF "$cmdline" /etc/default/grub; then
98 # already set things, exit
102 # required to show vga grub on d16, at least for t11
103 echo GRUB_TERMINAL=console >>/etc/default/grub
106 sed -ri 's/^ *GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="$cmdline"/' /etc/default/grub
107 sed -ri 's/^ *GRUB_TIMEOUT_STYLE=.*/GRUB_TIMEOUT_STYLE=menu/' /etc/default/grub
108 sed -ri 's/^ *GRUB_TIMEOUT=.*/GRUB_TIMEOUT=6/' /etc/default/grub
109 # on xenial, no grub is displayed at all. fix that.
110 # found just by noticing this in the config file, and a
111 # warning about it in error.log
112 sed -i '/^ *GRUB_HIDDEN_TIMEOUT/d' /etc/default/grub
114 if type -P update-grub2 &>/dev/null; then
123 # I prefer to stick with ifup/down or networkmanager: networkd is not in its
124 # own package, so cant use in other init systems. b. it works fine.
125 chroot
$FAI_ROOT bash
<<EOF
126 systemctl disable systemd-networkd.socket systemd-networkd networkd-dispatcher systemd-networkd-wait-online
127 systemctl mask systemd-networkd.socket systemd-networkd networkd-dispatcher systemd-networkd-wait-online