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