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