4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
6 if [[ $EUID != 0 ]]; then
7 echo "$0: error: expected to be root."
12 # note, $BASH_SOURCE is not defined here under fai.
13 src
=$
(dirname "$0")/p
/c
/machine_specific
/$HOSTNAME/filesystem
/etc
/ssh
15 if [[ -e $src && -e $dst ]]; then
16 # outside of fai context, we skip this
20 if ifclass VOL_STRETCH_BOOTSTRAP
; then
24 TPW
=/q
/root
/shadow
/traci-simple
28 ROOTPW
=/q
/root
/shadow
/standard
32 # generating a hashed password:
33 # under debian, you can do
34 # mkpasswd -m sha-512 -s >/q/root/shadow/standard
35 # On arch, best seems to be copy your shadow file to a temp location,
36 # then passwd, get out the new pass, then copy the shadow file back.
40 if [[ $pwfile && -e $pwfile ]]; then
41 printf "$user:" |
cat - "$pwfile" |
$ROOTCMD chpasswd
-e
43 echo "$0: warning: no pw set for $user" >&2
47 if ! $ROOTCMD getent passwd
${@: -1}; then
48 $ROOTCMD useradd
-m -s /bin
/bash $@
53 # 9 = user already exists. so we are idempotent.
58 if ifclass frodo
; then
61 # comparing iank's groups to traci, I see none she should join on arch
62 $ROOTCMD usermod
-a -G traci iank
64 $ROOTCMD getent group docker
&>/dev
/null ||
$ROOTCMD groupadd
-r docker
65 $ROOTCMD usermod
-a -G docker iank
67 # based on unison error, with 8192 from
68 # sysctl -a | grep fs.inotify.max_user_watches
69 #http://stackoverflow.com/questions/535768/what-is-a-reasonable-amount-of-inotify-watches-with-linux
71 f
=$target/etc
/sysctl.d
/99-sysctl.conf
72 key
=fs.inotify.max_user_watches
73 if [[ -e $f ]]; then sed -ri --follow-symlinks "/^\s*$key\s*=/d" $f; fi
74 echo "fs.inotify.max_user_watches = 1000000" >> $f
75 # applies it. it would be also be applied after a reboot
76 $ROOTCMD sysctl
--system
79 line
='iank ALL=(ALL) NOPASSWD: ALL'
80 if [[ ! -e $f ]] ||
! grep -xF "$line" $f; then
84 dir
=/p
/c
/machine_specific
/$HOSTNAME/.unison
85 $ROOTCMD mkdir
-p $dir
86 if ! $ROOTCMD test -L /root
/.unison
; then
87 $ROOTCMD rm -rf /root
/.unison
88 $ROOTCMD ln -s -T $dir /root
/.unison
91 $ROOTCMD chown
-R 1000:1000 $dir
93 $ROOTCMD chown
1000:1000 $dir
94 $ROOTCMD chmod 700 $dir
96 if [[ $dir == /p
]]; then break; fi
99 au
--system -s /bin
/false
--home-dir /var
/lib
/bitcoind bitcoin