updates for t11 and fsf
[automated-distro-installer] / fai / config / scripts / DEBIAN / 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 fcopy -riB /root
12
13
14 #### misc configurations
15 chroot $FAI_ROOT bash <<'EOFOUTER'
16 set -x
17 if getent group systemd-journal >/dev/null; then
18 # makes the journal be saved to disk.
19 mkdir -p /var/log/journal
20 chmod 755 /var/log/journal
21 fi
22 debconf-set-selections <<EOF
23 kexec-tools kexec-tools/load_kexec boolean false
24 EOF
25 apt-get install -y pxe-kexec
26
27 # this is usefull. Only thing reason I see this being disabled by default is
28 # that a non-root user can disrupt the system, eg cause a reboot.
29 sed -i '$a kernel.sysrq=1
30 /^kernel.sysrq=/d' /etc/sysctl.conf
31
32 EOFOUTER
33
34 cmdline_extra="$d16_cmdline $fsf_cmdline_extra"
35
36 # luks options, see man systemd-cryptsetup-generator
37 # all i know is that with luks.crypttab=no, swap still timed out on boot.
38 # and with rd.luks.crypttab=no, it works.
39 cmdline="rd.luks.crypttab=no net.ifnames=0 $cmdline_extra"
40
41 chroot $FAI_ROOT bash <<EOF
42 set -x
43 set -eE -o pipefail
44 # https://askubuntu.com/questions/33416/how-do-i-disable-the-boot-splash-screen-and-only-show-kernel-and-boot-text-inst
45
46 sed -ri 's/(^GRUB_CMDLINE_LINUX_DEFAULT=")quiet/\1/;s/^(GRUB_CMDLINE_LINUX_DEFAULT=".*) quiet([ "])/\1\2/' /etc/default/grub
47 sed -ri 's/(^GRUB_CMDLINE_LINUX_DEFAULT=")splash/\1/;s/^(GRUB_CMDLINE_LINUX_DEFAULT=".*) splash([ "])/\1\2/' /etc/default/grub
48
49 for arg in $cmdline; do
50 if ! grep "^GRUB_CMDLINE_LINUX_DEFAULT=.*[\" ]\${arg//./\\.}[\" ]" /etc/default/grub; then
51 sed -ri "s/^GRUB_CMDLINE_LINUX_DEFAULT=\"(.*)/GRUB_CMDLINE_LINUX_DEFAULT=\"\$arg \1/" /etc/default/grub
52 fi
53 done
54
55 if grep -qF "$cmdline" /etc/default/grub; then
56 # already set things, exit
57 exit 0
58 fi
59
60 # required to show vga grub on d16, at least for t11
61 echo GRUB_TERMINAL=console >>/etc/default/grub
62
63
64 sed -ri 's/^ *GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="$cmdline"/' /etc/default/grub
65 sed -ri 's/^ *GRUB_TIMEOUT_STYLE=.*/GRUB_TIMEOUT_STYLE=menu/' /etc/default/grub
66 sed -ri 's/^ *GRUB_TIMEOUT=.*/GRUB_TIMEOUT=6/' /etc/default/grub
67 # on xenial, no grub is displayed at all. fix that.
68 # found just by noticing this in the config file, and a
69 # warning about it in error.log
70 sed -i '/^ *GRUB_HIDDEN_TIMEOUT/d' /etc/default/grub
71
72 if type -P update-grub2 &>/dev/null; then
73 update-grub2
74 else
75 update-grub
76 fi
77
78 EOF
79
80
81 # I prefer to stick with ifup/down or networkmanager: networkd is not in its
82 # own package, so cant use in other init systems. b. it works fine.
83 chroot $FAI_ROOT bash <<EOF
84 systemctl disable systemd-networkd.socket systemd-networkd networkd-dispatcher systemd-networkd-wait-online
85 systemctl mask systemd-networkd.socket systemd-networkd networkd-dispatcher systemd-networkd-wait-online
86 EOF