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