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 ### begin set hostname
12 echo $hostname > /etc
/hostname
13 sed -i '/^127\.0\.1\.1/d' /etc
/hosts
14 echo "127.0.1.1 $hostname" >> /etc
/hosts
15 hostname
-F /etc
/hostname
18 TPW
=/q
/root
/shadow
/traci-simple
22 ROOTPW
=/q
/root
/shadow
/standard
26 # generating a hashed password:
27 # under debian, you can do
28 # mkpasswd -m sha-512 -s >/q/root/shadow/standard
29 # On arch, best seems to be copy your shadow file to a temp location,
30 # then passwd, get out the new pass, then copy the shadow file back.
34 if [[ $pwfile && -e $pwfile ]]; then
35 printf "$user:" |
cat - "$pwfile" |
$ROOTCMD chpasswd
-e
37 echo "$0: warning: no pw set for $user"
41 if ! $ROOTCMD getent passwd
$1; then
42 $ROOTCMD useradd
-m $1 -s /bin
/bash ||
[[ $?
== 9 ]]
46 echo "IANNNNNNN 222222222, $ROOTPW"
50 # 9 = user already exists. so we are idempotent.
55 if ifclass frodo
; then
58 # comparing ian's groups to traci, I see none she should join on arch
59 $ROOTCMD usermod
-a -G traci ian
62 # based on unison error, with 8192 from
63 # sysctl -a | grep fs.inotify.max_user_watches
64 #http://stackoverflow.com/questions/535768/what-is-a-reasonable-amount-of-inotify-watches-with-linux
66 f
=$target/etc
/sysctl.d
/99-sysctl.conf
67 key
=fs.inotify.max_user_watches
68 if [[ -e $f ]]; then sed -ri "/^\s*$key\s*=/d" $f; fi
69 echo "fs.inotify.max_user_watches = 1000000" >> $f
70 # applies it. it would be also be applied after a reboot
71 $ROOTCMD sysctl
--system
74 line
='ian ALL=(ALL) NOPASSWD: ALL'
75 if [[ ! -e $f ]] ||
! grep -xF "$line" $f; then
80 dir
=/q
/p
/c
/machine_specific
/$HOSTNAME/.unison
81 $ROOTCMD mkdir
-p $dir
83 $ROOTCMD rm -rf /root
/.unison
84 $ROOTCMD ln -sf $dir /root
85 $ROOTCMD ln -sf /q
/p
/
87 $ROOTCMD chown
-R 1000:1000 $dir
89 $ROOTCMD chown
1000:1000 $dir
90 $ROOTCMD chmod 700 $dir
92 [[ $dir != /q
]] ||
break