various fixes and improvements
[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 $ROOTCMD adduser --disabled-password --gecos ian ian
7
8 if [[ ! $ROOTPW ]]; then
9 echo "$0: error: empty \$ROOTPW"
10 exit 1
11 fi
12
13 $ROOTCMD usermod -p "$ROOTPW" ian
14
15 if ifclass STABLE; then
16 fcopy -M /etc/apt/preferences
17 fi
18
19 if ifclass DEBIAN; then
20 fcopy -M /etc/apt/preferences.d/unstable
21 fcopy -riM /etc/apt/sources.list.d
22 fi
23
24
25 # note:
26 # fcopy -i = ignore nonmatching class error, always return 0.
27
28 f=/target/home/ian/.ssh/authorized_keys
29 if [[ ! -L $f || -e $f ]]; then
30 fcopy -r -M /home/ian/.ssh
31 else
32 echo "$0: info: $f exists"
33 fi
34 /var/lib/fai/config/distro-install-common/end
35
36 rm -f /target/etc/apt/sources.list
37
38 chroot /target bash <<'EOF'
39 set -eE -o pipefail
40 chown -R 1000:1000 /home/ian/.ssh
41 chmod -R u=Xrw,og= /home/ian/.ssh
42 rm -rf /root/.ssh
43 cp -rL /home/ian/.ssh /root
44 chown -R root:root /root/.ssh
45 chmod 700 /root/.ssh
46
47 # default jessie groups + kvm & systemd-journal
48 usermod -aG cdrom,floppy,sudo,audio,dip,video,plugdev,netdev,systemd-journal ian
49 EOF
50
51
52 $ROOTCMD apt-get -y install unison-gtk
53 if ifclass STABLE; then
54 # don't think this is needed since I figured out how to
55 # deal with mismatching unison compilers, but I don't
56 # see any reason to revert it, since it only installs
57 # a single package which is primarily a single binary
58 $ROOTCMD apt-get -y install unison-gtk/testing
59 fi
60
61
62
63 $ROOTCMD adduser --disabled-password --gecos traci traci
64 $ROOTCMD usermod -a -G traci ian
65 # reading through the groups that ian is in but traci isn't,
66 for g in plugdev audio video cdrom; do
67 $ROOTCMD usermod -a -G $g traci
68 done
69
70 if ifclass frodo; then
71 $ROOTCMD usermod -p "$(cat /var/lib/fai/config/distro-install-common/traci-simple)" traci
72 fi
73
74
75 # makes the journal be saved to disk.
76 $ROOTCMD mkdir -p /target/var/log/journal
77 $ROOTCMD chmod 755 /target/var/log/journal