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 -s /bin
/bash
$1 ||
[[ $?
== 9 ]]
47 # 9 = user already exists. so we are idempotent.
52 if ifclass frodo
; then
55 # comparing ian's groups to traci, I see none she should join on arch
56 $ROOTCMD usermod
-a -G traci ian
59 # based on unison error, with 8192 from
60 # sysctl -a | grep fs.inotify.max_user_watches
61 #http://stackoverflow.com/questions/535768/what-is-a-reasonable-amount-of-inotify-watches-with-linux
63 f
=$target/etc
/sysctl.d
/99-sysctl.conf
64 key
=fs.inotify.max_user_watches
65 if [[ -e $f ]]; then sed -ri --follow-symlinks "/^\s*$key\s*=/d" $f; fi
66 echo "fs.inotify.max_user_watches = 1000000" >> $f
67 # applies it. it would be also be applied after a reboot
68 $ROOTCMD sysctl
--system
71 line
='ian ALL=(ALL) NOPASSWD: ALL'
72 if [[ ! -e $f ]] ||
! grep -xF "$line" $f; then
77 dir
=/q
/p
/c
/machine_specific
/$HOSTNAME/.unison
78 $ROOTCMD mkdir
-p $dir
79 if ! $ROOTCMD test -L /root
/.unison
; then
80 $ROOTCMD rm -rf /root
/.unison
81 $ROOTCMD ln -s -T $dir /root
/.unison
84 $ROOTCMD ln -sf /q
/p
/
85 $ROOTCMD chown
-R 1000:1000 $dir
87 $ROOTCMD chown
1000:1000 $dir
88 $ROOTCMD chmod 700 $dir
90 [[ $dir != /q
]] ||
break