install chboot to /boot in case its needed
[automated-distro-installer] / fai / config / scripts / GRUB_PC / 11-ian
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 if ! type -t fcopy &>/dev/null; then
12 sudo apt-get -y install fai-client
13 fi
14
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 EOFOUTER
26
27 fcopy -r /boot # -r = recursive
28 # note: # fcopy -i = ignore nonmatching class error, always return 0.
29 # this is also done by FABASE/10-misc by default.
30 fcopy -ir /root
31 if ifclass STABLE_BOOTSTRAP; then
32 fcopy -ri /etc/systemd/system
33 chroot $FAI_ROOT bash <<'EOFOUTER'
34 systemctl enable fai_check.service
35 EOFOUTER
36 exit 0
37 fi
38
39 dir=/q/root/shadow
40 fai_shadow=$FAI/distro-install-common/shadow
41 if [[ ! -e $dir && -e $fai_shadow ]]; then
42 mkdir -p $dir
43 mount -o bind $fai_shadow $dir
44 fi
45 $FAI/distro-install-common/end
46
47
48 # these get copied in an earlier stage by fai, but leaving it here since
49 # I run this as a single post-fai script to update things that have changed.
50 fcopy -ri /etc/apt/preferences.d
51 fcopy -ri /etc/apt/sources.list.d
52 $ROOTCMD apt-get update
53
54
55
56 rm -f $FAI_ROOT/etc/apt/sources.list
57
58 chroot $FAI_ROOT bash <<'EOF'
59 set -eE -o pipefail
60 mkdir -p /home/ian/.ssh
61 f=/root/.ssh/authorized_keys
62 if [[ -e $f ]]; then
63 cp $f /home/ian/.ssh
64 fi
65 chown -R 1000:1000 /home/ian/.ssh
66 chmod -R u=Xrw,og= /home/ian/.ssh
67 rm -rf /root/.ssh
68 cp -rL /home/ian/.ssh /root
69 chown -R root:root /root/.ssh
70 chmod 700 /root/.ssh
71
72
73 # default jessie groups + kvm, systemd-journal, adm
74 usermod -aG adm,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev ian
75
76 if getent group systemd-journal >/dev/null; then
77 usermod -aG systemd-journal ian
78 fi
79 # https://askubuntu.com/questions/33416/how-do-i-disable-the-boot-splash-screen-and-only-show-kernel-and-boot-text-inst
80 # it suggests not having plymouth-theme-ubuntu-text, but
81 # making it not installed then kills plymouth, then makes
82 # the system not boot.
83 sed -ri 's/(^ *GRUB_CMDLINE_LINUX.*)quiet splash/\1/' /etc/default/grub
84 # on xenial, no grub is displayed at all. fix that.
85 # found just by noticing this in the config file, and a
86 # warning about it in error.log
87 sed -i '/^ *GRUB_HIDDEN_TIMEOUT/d' /etc/default/grub
88 update-grub2
89 EOF
90
91
92 # reading through the groups that ian is in but traci isn't,
93 for g in plugdev audio video cdrom; do
94 $ROOTCMD usermod -a -G $g traci
95 done