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" "$*"; "$@"; }
29 source $FAI/distro-install-common
/bash-misc-functions
33 # in bullseye, installing systemd-resolved says: Converting
34 # /etc/resolv.conf to a symlink to
35 # /run/systemd/resolve/stub-resolv.conf... which breaks
36 # resolution. This happens to be the first script we install a package
37 # after that. This should do nothing in a fai-wrapper situation.
38 if [[ ! -s $target/etc
/resolv.conf
]]; then
39 m
ls -la $target/etc
/resolv.conf ||
:
40 # Keep the symlink in place, systemd-resolved should change the file
42 mkdir
-p $target/run
/systemd
/resolve
43 if [[ ! -s /etc
/resolv.conf
]] && ! host google.com
; then
44 echo "ERROR: empty resolv.conf & failed dns resolution. exiting 1" >&2
47 cat /etc
/resolv.conf
>$target/etc
/resolv.conf
52 #### misc configurations
53 chroot
$FAI_ROOT bash
<<'EOFOUTER'
55 if getent group systemd-journal >/dev/null; then
56 # makes the journal be saved to disk.
57 mkdir -p /var/log/journal
58 chmod 755 /var/log/journal
60 debconf-set-selections <<EOF
61 kexec-tools kexec-tools/load_kexec boolean false
64 # This used to be pxe-kexec. For some reason pxe-kexec is not in
65 # bookworm. kexec-tools is
66 # something pxe-kexec depended on and might be useful.
67 # todo: figure out why and get it installed.
68 apt-get install -y kexec-tools
70 # this is usefull. Only thing reason I see this being disabled by default is
71 # that a non-root user can disrupt the system, eg cause a reboot.
72 sed -i '$a kernel.sysrq=1
73 /^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"
84 u
/etc
/default
/grub.d
/iank.cfg
<<'EOF'
85 # note: in git history, you can see code that modified the existing
86 # GRUB_CMDLINE_LINUX_DEFAULT. That was being cautious in case something
87 # else modified it, but experience has shown nothing else modifying it.
89 GRUB_CMDLINE_LINUX_DEFAULT="$cmdline"
91 # on xenial, no grub is displayed at all. fix that.
92 # found just by noticing a warning about it in error.log
94 GRUB_TIMEOUT_STYLE=menu
96 # grub tries to detect error in booting and then wait longer with this entry.
97 # but that detection doesn't work for us because we have btrfs /boot, and so it flags
99 GRUB_RECORDFAIL_TIMEOUT=4
106 # I prefer to stick with ifup/down or networkmanager: networkd is not in its
107 # own package, so cant use in other init systems. b. it works fine.
108 chroot
$FAI_ROOT bash
<<EOF
109 systemctl disable systemd-networkd.socket systemd-networkd networkd-dispatcher systemd-networkd-wait-online
110 systemctl mask systemd-networkd.socket systemd-networkd networkd-dispatcher systemd-networkd-wait-online