#!/bin/bash -x set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR if [[ $EUID != 0 ]]; then echo "$0: error: expected to be root." exit 1 fi if ! type -t fcopy &>/dev/null; then sudo apt-get -y install fai-client fi chroot $FAI_ROOT bash <<'EOFOUTER' set -eE -o pipefail if getent group systemd-journal >/dev/null; then # makes the journal be saved to disk. mkdir -p /var/log/journal chmod 755 /var/log/journal fi debconf-set-selections < 60*60*2 )); then i=0 while fuser $FAI_ROOT/var/lib/dpkg/lock &>/dev/null; do sleep 1 i=$(( i+1 )) if (( i > 300 )); then echo "error: timed out waiting for /var/lib/dpkg/lock" >&2 exit 1 fi $ROOTCMD apt-get update done fi chroot $FAI_ROOT bash <<'EOF' #### begin .ssh setup ### set -eE -o pipefail mkdir -p /home/iank/.ssh f=/root/.ssh/authorized_keys if [[ -e $f ]]; then cp $f /home/iank/.ssh fi chown -R 1000:1000 /home/iank/.ssh chmod -R u=Xrw,og= /home/iank/.ssh rm -rf /root/.ssh # remove broken symlinks or the following cp will fail find /home/iank/.ssh -xtype l -exec rm '{}' \; cp -rL /home/iank/.ssh /root chown -R root:root /root/.ssh chmod 700 /root/.ssh #### end .ssh setup ### # this is needed to enable resolvconf, making /etc/resolv.conf be a symlink. # why? i dun know, it\'s really dumb. dpkg-reconfigure -fnoninteractive resolvconf # default jessie groups + kvm, systemd-journal, adm for g in adm cdrom floppy sudo audio dip video plugdev netdev; do if getent gropu $g >/dev/null; then usermod -aG $g iank fi done if getent group systemd-journal >/dev/null; then usermod -aG systemd-journal iank fi # this is usefull. Only thing reason I see this being disabled by default is # that a normal user can disrupt the system, eg cause a reboot. sed -i '$a kernel.sysrq=1 /^kernel.sysrq=/d' /etc/sysctl.conf EOF if [[ $FAI_ACTION != dirinstall ]]; then # luks options, see man systemd-cryptsetup-generator # all i know is that with luks.crypttab=no, swap still timed out on boot. # and with rd.luks.crypttab=no, it works. cmdline="rd.luks.crypttab=no console=ttyS0" if ifclass LINODE; then speed=19200 cmdline+=",${speed}n8" cmdline="rd.luks.crypttab=no console=ttyS0,${speed}n8" else speed=115200 cmdline+=",${speed}n8 console=tty0" fi cat >$FAI_ROOT/etc/grub.d/40_custom </etc/initramfs-tools/modules update-initramfs -u -k all EOF fi fi # reading through the groups that iank is in but user2 isn't, for g in plugdev audio video cdrom; do $ROOTCMD usermod -a -G $g user2 done