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
26 ROOTPW
=/q
/root
/shadow
/standard
29 ROOTPW
=/q
/root
/shadow
/standard
33 # generating a hashed password:
34 # under debian, you can do
35 # mkpasswd -m sha-512 -s >/q/root/shadow/standard
36 # On arch, best seems to be copy your shadow file to a temp location,
37 # then passwd, get out the new pass, then copy the shadow file back.
41 if [[ $pwfile && -e $pwfile ]]; then
42 printf "$user:" |
cat - "$pwfile" |
$ROOTCMD chpasswd
-e
44 echo "$0: warning: no pw set for $user" >&2
48 if ! $ROOTCMD getent passwd
${@: -1}; then
49 $ROOTCMD useradd
-m -s /bin
/bash $@
54 # 9 = user already exists. so we are idempotent.
59 if ifclass frodo
; then
62 # comparing iank's groups to traci, I see none she should join on arch
63 $ROOTCMD usermod
-a -G traci iank
65 $ROOTCMD getent group docker
&>/dev
/null ||
$ROOTCMD groupadd
-r docker
66 $ROOTCMD usermod
-a -G docker iank
68 # based on unison error, with 8192 from
69 # sysctl -a | grep fs.inotify.max_user_watches
70 #http://stackoverflow.com/questions/535768/what-is-a-reasonable-amount-of-inotify-watches-with-linux
72 f
=$target/etc
/sysctl.d
/99-sysctl.conf
73 key
=fs.inotify.max_user_watches
74 if [[ -e $f ]]; then sed -ri --follow-symlinks "/^\s*$key\s*=/d" $f; fi
75 echo "fs.inotify.max_user_watches = 1000000" >> $f
76 # applies it. it would be also be applied after a reboot
77 $ROOTCMD sysctl
--system
80 line
='iank ALL=(ALL) NOPASSWD: ALL'
81 if [[ ! -e $f ]] ||
! grep -xF "$line" $f; then
85 dir
=/p
/c
/machine_specific
/$HOSTNAME/.unison
86 $ROOTCMD mkdir
-p $dir
87 if ! $ROOTCMD test -L /root
/.unison
; then
88 $ROOTCMD rm -rf /root
/.unison
89 $ROOTCMD ln -s -T $dir /root
/.unison
92 $ROOTCMD chown
-R 1000:1000 $dir
94 $ROOTCMD chown
1000:1000 $dir
95 $ROOTCMD chmod 700 $dir
97 if [[ $dir == /p
]]; then break; fi
100 au
--system -s /bin
/false
--home-dir /var
/lib
/bitcoind bitcoin