various fixes
[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 dir=/q/root/shadow
16 fai_shadow=$FAI/distro-install-common/shadow
17 if [[ ! -e $dir && -e $fai_shadow ]]; then
18 mkdir -p $dir
19 mount -o bind $fai_shadow $dir
20 fi
21 $FAI/distro-install-common/end
22
23 if ifclass STABLE || ifclass LINODESTABLE; then
24 fcopy -M /etc/apt/preferences
25 fi
26
27 if ifclass DEBIAN; then
28 fcopy -M /etc/apt/preferences.d/unstable
29 fcopy -riM /etc/apt/sources.list.d
30 $ROOTCMD apt-get update
31 fi
32
33
34 # note:
35 # fcopy -i = ignore nonmatching class error, always return 0.
36
37 # for lj, this will be empty and fail
38 fcopy -riM /home/ian/.ssh
39
40 rm -f $FAI_ROOT/etc/apt/sources.list
41
42 chroot $FAI_ROOT bash <<'EOF'
43 set -eE -o pipefail
44 mkdir -p /home/ian/.ssh
45 f=/root/.ssh/authorized_keys
46 if [[ -e $f ]]; then
47 cp $f /home/ian/.ssh
48 fi
49 chown -R 1000:1000 /home/ian/.ssh
50 chmod -R u=Xrw,og= /home/ian/.ssh
51 rm -rf /root/.ssh
52 cp -rL /home/ian/.ssh /root
53 chown -R root:root /root/.ssh
54 chmod 700 /root/.ssh
55
56 # default jessie groups + kvm, systemd-journal, adm
57 usermod -aG adm,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev,systemd-journal ian
58 EOF
59
60
61 # reading through the groups that ian is in but traci isn't,
62 for g in plugdev audio video cdrom; do
63 $ROOTCMD usermod -a -G $g traci
64 done
65
66 # makes the journal be saved to disk.
67 $ROOTCMD mkdir -p $FAI_ROOT/var/log/journal
68 $ROOTCMD chmod 755 $FAI_ROOT/var/log/journal