4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
6 if [[ $EUID != 0 ]]; then
7 echo "$0: error: expected to be root."
11 TPW
=/q
/root
/shadow
/traci-simple
15 ROOTPW
=/q
/root
/shadow
/standard
19 # generating a hashed password:
20 # under debian, you can do
21 # mkpasswd -m sha-512 -s >/q/root/shadow/standard
22 # On arch, best seems to be copy your shadow file to a temp location,
23 # then passwd, get out the new pass, then copy the shadow file back.
27 if [[ $pwfile && -e $pwfile ]]; then
28 printf "$user:" |
cat - "$pwfile" |
$ROOTCMD chpasswd
-e
30 echo "$0: warning: no pw set for $user" >&2
34 if ! $ROOTCMD getent passwd
$1; then
35 $ROOTCMD useradd
-m -s /bin
/bash
$1 ||
[[ $?
== 9 ]]
40 # 9 = user already exists. so we are idempotent.
45 if ifclass frodo
; then
48 # comparing ian's groups to traci, I see none she should join on arch
49 $ROOTCMD usermod
-a -G traci ian
52 # based on unison error, with 8192 from
53 # sysctl -a | grep fs.inotify.max_user_watches
54 #http://stackoverflow.com/questions/535768/what-is-a-reasonable-amount-of-inotify-watches-with-linux
56 f
=$target/etc
/sysctl.d
/99-sysctl.conf
57 key
=fs.inotify.max_user_watches
58 if [[ -e $f ]]; then sed -ri --follow-symlinks "/^\s*$key\s*=/d" $f; fi
59 echo "fs.inotify.max_user_watches = 1000000" >> $f
60 # applies it. it would be also be applied after a reboot
61 $ROOTCMD sysctl
--system
64 line
='ian ALL=(ALL) NOPASSWD: ALL'
65 if [[ ! -e $f ]] ||
! grep -xF "$line" $f; then
70 dir
=/q
/p
/c
/machine_specific
/$HOSTNAME/.unison
71 $ROOTCMD mkdir
-p $dir
72 if ! $ROOTCMD test -L /root
/.unison
; then
73 $ROOTCMD rm -rf /root
/.unison
74 $ROOTCMD ln -s -T $dir /root
/.unison
77 $ROOTCMD ln -sf /q
/p
/
78 $ROOTCMD chown
-R 1000:1000 $dir
80 $ROOTCMD chown
1000:1000 $dir
81 $ROOTCMD chmod 700 $dir
83 [[ $dir != /q
]] ||
break