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 TPW
=/q
/root
/shadow
/traci-simple
22 ROOTPW
=/q
/root
/shadow
/standard
25 ROOTPW
=/q
/root
/shadow
/standard
29 # generating a hashed password:
30 # under debian, you can do
31 # mkpasswd -m sha-512 -s >/q/root/shadow/standard
32 # On arch, best seems to be copy your shadow file to a temp location,
33 # then passwd, get out the new pass, then copy the shadow file back.
37 if [[ $pwfile && -e $pwfile ]]; then
38 printf "$user:" |
cat - "$pwfile" |
$ROOTCMD chpasswd
-e
40 echo "$0: warning: no pw set for $user" >&2
43 au
() { # add user. i don't use adduser for portability
44 if ! $ROOTCMD getent passwd
${@: -1}; then
45 $ROOTCMD useradd
-Um -s /bin
/bash $@
51 # only setup root pass for bootstrap vol
52 if ifclass VOL_STRETCH_BOOTSTRAP
; then
57 # return of 9 = user already exists. so we are idempotent.
62 if ifclass frodo
; then
65 # comparing iank's groups to traci, I see none she should join on arch
66 $ROOTCMD usermod
-a -G traci iank
68 $ROOTCMD getent group docker
&>/dev
/null ||
$ROOTCMD groupadd
-r docker
69 $ROOTCMD usermod
-a -G docker iank
71 # based on unison error, with 8192 from
72 # sysctl -a | grep fs.inotify.max_user_watches
73 #http://stackoverflow.com/questions/535768/what-is-a-reasonable-amount-of-inotify-watches-with-linux
75 f
=$target/etc
/sysctl.d
/99-sysctl.conf
76 key
=fs.inotify.max_user_watches
77 if [[ -e $f ]]; then sed -ri --follow-symlinks "/^\s*$key\s*=/d" $f; fi
78 echo "fs.inotify.max_user_watches = 1000000" >> $f
79 # applies it. it would be also be applied after a reboot
80 $ROOTCMD sysctl
--system
83 line
='iank ALL=(ALL) NOPASSWD: ALL'
84 if [[ ! -e $f ]] ||
! grep -xF "$line" $f; then
88 dir
=/p
/c
/machine_specific
/$HOSTNAME/.unison
89 $ROOTCMD mkdir
-p $dir
90 if ! $ROOTCMD test -L /root
/.unison
; then
91 $ROOTCMD rm -rf /root
/.unison
92 $ROOTCMD ln -s -T $dir /root
/.unison
95 $ROOTCMD chown
-R 1000:1000 $dir
97 $ROOTCMD chown
1000:1000 $dir
98 $ROOTCMD chmod 700 $dir
100 if [[ $dir == /p
]]; then break; fi
103 au
--system -s /bin
/false
--home-dir /var
/lib
/bitcoind bitcoin