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'
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
21 debconf-set-selections <<EOF
22 kexec-tools kexec-tools/load_kexec boolean false
24 apt-get install -y pxe-kexec
28 # -i = ignore non-matching class warnings, always exit 0
29 # -B = no backup files
31 # this is also done by FABASE/10-misc by default.
35 src
=$FAI/distro-install-common
/shadow
37 if [[ ! -e $dst && -e $src ]]; then
38 # outside of fai context, we skip this
40 mount
-o bind $src $dst
43 $FAI/distro-install-common
/end
44 if ifclass VOL_STRETCH_BOOTSTRAP
; then
45 fcopy
-ri /etc
/systemd
/system
46 chroot
$FAI_ROOT bash
<<'EOFOUTER'
47 systemctl enable fai_check.service
49 exit 0 # avoid unnecessary stuff in bootstrap vol
53 # these get copied in an earlier stage by fai, but leaving it here since
54 # I run this as a single post-fai script to update things that have changed.
56 # outside of fai, this seems to regularly lead to
57 # E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
58 # so add a sleep. 1 sec is probably way more than needed.
60 $ROOTCMD apt-get update
63 chroot
$FAI_ROOT bash
<<'EOF'
64 #### begin .ssh setup ###
66 mkdir -p /home/iank/.ssh
67 f=/root/.ssh/authorized_keys
71 chown -R 1000:1000 /home/iank/.ssh
72 chmod -R u=Xrw,og= /home/iank/.ssh
74 # remove broken symlinks or the following cp will fail
75 find /home/iank/.ssh -xtype l -exec rm '{}' \;
76 cp -rL /home/iank/.ssh /root
77 chown -R root:root /root/.ssh
79 #### end .ssh setup ###
81 # this is needed to enable resolvconf, making /etc/resolv.conf be a symlink.
82 # why? i dun know, it\'s really dumb.
83 dpkg-reconfigure -fnoninteractive resolvconf
85 # default jessie groups + kvm, systemd-journal, adm
86 usermod -aG adm,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev iank
88 if getent group systemd-journal >/dev/null; then
89 usermod -aG systemd-journal iank
93 # this is usefull. Only thing reason I see this being disabled by default is
94 # that a normal user can disrupt the system, eg cause a reboot.
95 sed -i '$a kernel.sysrq=1
96 /^kernel.sysrq=/d' /etc/sysctl.conf
100 if [[ $FAI_ACTION != dirinstall
]]; then
102 cat >$FAI_ROOT/etc
/grub.d
/40_custom
<<'EOF'
105 # This file provides an easy way to add custom menu entries. Simply type the
106 # menu entries you want to add after this comment. Be careful not to change
107 # the 'exec tail' line above.
109 # https://www.coreboot.org/Serial_console # tty
110 # but removed unneeded stuff
112 serial --speed=115200
113 terminal_input --append serial
114 terminal_output --append serial
117 chroot
$FAI_ROOT bash
<<'EOF'
118 # https://askubuntu.com/questions/33416/how-do-i-disable-the-boot-splash-screen-and-only-show-kernel-and-boot-text-inst
119 # it suggests not having plymouth-theme-ubuntu-text, but
120 # making it not installed then kills plymouth, then makes
121 # the system not boot.
122 sed -ri 's/(^ *GRUB_CMDLINE_LINUX.*)quiet splash/\1/' /etc/default/grub
124 # todo: not sure, but this might screw up systems without a serial port
125 # and thus need a conditional.
126 sed -ri 's/^ *GRUB_CMDLINE_LINUX_DEFAULT="/\0console=ttyS0,115200 console=tty0 /' /etc/default/grub
127 # on xenial, no grub is displayed at all. fix that.
128 # found just by noticing this in the config file, and a
129 # warning about it in error.log
130 sed -i '/^ *GRUB_HIDDEN_TIMEOUT/d' /etc/default/grub
137 # reading through the groups that iank is in but user2 isn't,
138 for g
in plugdev audio video cdrom
; do
139 $ROOTCMD usermod
-a -G $g user2