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.
14 src
=$
(dirname "$0")/p
/c
/machine_specific
/$HOSTNAME/filesystem
/etc
/ssh
16 if [[ -e $src && -e $dst ]]; then
17 # outside of fai context or setting up a brand new host, we skip this
21 USER2PW
=/q
/root
/shadow
/user2
23 ROOTPW
=/q
/root
/shadow
/ziva
25 # if doesn't exist, we dont set one
26 ROOTPW
=/q
/root
/shadow
/standard
30 # generating a hashed password:
31 # under debian, you can do
32 # mkpasswd -m sha-512 -s >/q/root/shadow/standard
33 # On arch, best seems to be copy your shadow file to a temp location,
34 # then passwd, get out the new pass, then copy the shadow file back.
38 if [[ $pwfile && -e $pwfile ]]; then
39 printf "$user:" |
cat - "$pwfile" |
$ROOTCMD chpasswd
-e
41 echo "$0: warning: no pw set for $user" >&2
44 au
() { # add user. i don't use adduser for portability
45 if ! $ROOTCMD getent passwd
${@: -1}; then
46 $ROOTCMD useradd
-Um -s /bin
/bash $@
52 # only setup root pass for bootstrap vol
53 if ifclass VOL_STRETCH_BOOTSTRAP
; then
58 # return of 9 = user already exists. so we are idempotent.
63 if ifclass frodo
; then
66 # comparing iank's groups to user2, I see none she should join on arch
67 $ROOTCMD usermod
-a -G user2 iank
70 $ROOTCMD getent group docker
&>/dev
/null ||
$ROOTCMD groupadd
-r docker
71 $ROOTCMD usermod
-a -G docker iank
73 # based on unison error, with 8192 from
74 # sysctl -a | grep fs.inotify.max_user_watches
75 #http://stackoverflow.com/questions/535768/what-is-a-reasonable-amount-of-inotify-watches-with-linux
76 f
=$target/etc
/sysctl.d
/99-sysctl.conf
77 key
=fs.inotify.max_user_watches
78 if [[ -e $f ]]; then sed -ri --follow-symlinks "/^\s*$key\s*=/d" $f; fi
79 echo "fs.inotify.max_user_watches = 50000" >> $f
80 # applies it. it would be also be applied after a reboot
81 $ROOTCMD sysctl
--system
84 line
='iank ALL=(ALL) NOPASSWD: ALL'
85 if [[ ! -e $f ]] ||
! grep -xF "$line" $f; then
90 au
--system -s /bin
/false
--home-dir /var
/lib
/bitcoind bitcoin