better support for systems with no pxe
[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
12 if ! type -t fcopy &>/dev/null; then
13 sudo apt-get -y install fai-client
14 fi
15
16 chroot $FAI_ROOT bash <<'EOFOUTER'
17 debconf-set-selections <<EOF
18 kexec-tools kexec-tools/load_kexec boolean false
19 EOF
20 apt-get install -y pxe-kexec
21 EOFOUTER
22
23 # note: # fcopy -i = ignore nonmatching class error, always return 0.
24 # this is also done by FABASE/10-misc by default.
25 fcopy -ir /root
26 if ifclass STABLE_BOOTSTRAP; then
27 fcopy -ri /etc/systemd/system
28 chroot $FAI_ROOT bash <<'EOFOUTER'
29 systemctl enable fai_check.service
30 EOFOUTER
31 exit 0
32 fi
33
34 dir=/q/root/shadow
35 fai_shadow=$FAI/distro-install-common/shadow
36 if [[ ! -e $dir && -e $fai_shadow ]]; then
37 mkdir -p $dir
38 mount -o bind $fai_shadow $dir
39 fi
40 $FAI/distro-install-common/end
41
42
43 # these get copied in an earlier stage by fai, but leaving it here since
44 # I run this as a single post-fai script to update things that have changed.
45 fcopy -ri /etc/apt/preferences.d
46 fcopy -ri /etc/apt/sources.list.d
47 $ROOTCMD apt-get update
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