4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
6 if [[ $EUID != 0 ]]; then
7 echo "$0: error: expected to be root."
11 if ! type -t fcopy
&>/dev
/null
; then
12 sudo apt-get
-y install fai-client
15 chroot
$FAI_ROOT bash
<<'EOFOUTER'
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
22 debconf-set-selections <<EOF
23 kexec-tools kexec-tools/load_kexec boolean false
25 apt-get install -y pxe-kexec
29 # -i = ignore non-matching class warnings, always exit 0
30 # -B = no backup files
32 # this is also done by FABASE/10-misc by default.
36 src
=$FAI/distro-install-common
/shadow
38 if [[ ! -e $dst && -e $src ]]; then
39 # outside of fai context, we skip this
41 mount
-o bind $src $dst
44 $FAI/distro-install-common
/end
45 if ifclass VOL_STRETCH_BOOTSTRAP
; then
46 fcopy
-riM /etc
/systemd
/system
47 chroot
$FAI_ROOT bash
<<'EOFOUTER'
48 systemctl enable fai_check.service
50 exit 0 # avoid unnecessary stuff in bootstrap vol
54 # these get copied in an earlier stage by fai, but leaving it here since
55 # I run this as a single post-fai script to update things that have changed.
57 # outside of fai, this seems to regularly lead to
58 # E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
59 # so add a sleep. 1 sec is probably way more than needed.
61 $ROOTCMD apt-get update
64 chroot
$FAI_ROOT bash
<<'EOF'
65 #### begin .ssh setup ###
67 mkdir -p /home/iank/.ssh
68 f=/root/.ssh/authorized_keys
72 chown -R 1000:1000 /home/iank/.ssh
73 chmod -R u=Xrw,og= /home/iank/.ssh
75 # remove broken symlinks or the following cp will fail
76 find /home/iank/.ssh -xtype l -exec rm '{}' \;
77 cp -rL /home/iank/.ssh /root
78 chown -R root:root /root/.ssh
80 #### end .ssh setup ###
82 # this is needed to enable resolvconf, making /etc/resolv.conf be a symlink.
83 # why? i dun know, it\'s really dumb.
84 dpkg-reconfigure -fnoninteractive resolvconf
86 # default jessie groups + kvm, systemd-journal, adm
87 usermod -aG adm,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev iank
89 if getent group systemd-journal >/dev/null; then
90 usermod -aG systemd-journal iank
94 # this is usefull. Only thing reason I see this being disabled by default is
95 # that a normal user can disrupt the system, eg cause a reboot.
96 sed -i '$a kernel.sysrq=1
97 /^kernel.sysrq=/d' /etc/sysctl.conf
101 if [[ $FAI_ACTION != dirinstall
]]; then
104 if ifclass BUSTER_LINODE
; then
106 # luks.crypttab=no see man systemd-cryptsetup-generator
107 cmdline
="luks.crypttab=no console=ttyS0,${speed}n8"
110 cmdline
="luks.crypttab=no console=ttyS0,${speed} console=tty0"
113 cat >$FAI_ROOT/etc
/grub.d
/40_custom
<<EOF
116 # This file provides an easy way to add custom menu entries. Simply type the
117 # menu entries you want to add after this comment. Be careful not to change
118 # the 'exec tail' line above.
120 # https://www.coreboot.org/Serial_console # tty
121 # but removed unneeded stuff
123 serial --speed=$speed
124 terminal_input --append serial
125 terminal_output --append serial
130 chroot
$FAI_ROOT bash
<<EOF
132 # https://askubuntu.com/questions/33416/how-do-i-disable-the-boot-splash-screen-and-only-show-kernel-and-boot-text-inst
133 # we remove quiet and splash, and all thats left is what we want
135 sed -ri 's/^ *GRUB_CMDLINE_LINUX_DEFAULT=.*"/GRUB_CMDLINE_LINUX_DEFAULT="$cmdline"/' /etc/default/grub
136 # on xenial, no grub is displayed at all. fix that.
137 # found just by noticing this in the config file, and a
138 # warning about it in error.log
139 sed -i '/^ *GRUB_HIDDEN_TIMEOUT/d' /etc/default/grub
143 # Just include all of them for now incase we are creating
144 # an install for a different machine.. in distro-begin, we
145 # slim it down to whats used.
146 find /lib/modules/*/kernel/drivers/net /lib/modules/*/kernel/net -type f -name '*.ko' -printf "%f\n" | sed 's/.ko$//' | sort -u >/etc/initramfs-tools/modules
147 update-initramfs -u -k all
152 # reading through the groups that iank is in but user2 isn't,
153 for g
in plugdev audio video cdrom
; do
154 $ROOTCMD usermod
-a -G $g user2