small fixes and config changes
[automated-distro-installer] / fai / config / distro-install-common / end
index 666b781bf8cb98748ee5d191da634d7eb4e1b0dd..9c194fa19cc3cf90ee9889bd69809e6fee18e888 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash -x
 
 set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
 
 
@@ -9,8 +9,32 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
 # based on unison error, with 8192 from
 # sysctl -a | grep fs.inotify.max_user_watches
 #http://stackoverflow.com/questions/535768/what-is-a-reasonable-amount-of-inotify-watches-with-linux
-echo "fs.inotify.max_user_watches = 1000000" >> $target/etc/sysctl.d/99-sysctl.conf
+
+f=$target/etc/sysctl.d/99-sysctl.conf
+key=fs.inotify.max_user_watches
+if [[ -e $f ]]; then sed -ri "/^\s*$key\s*=/d" $f; fi
+echo "fs.inotify.max_user_watches = 1000000" >> $f
 # if we weren't rebooting, you could apply it now with:
 # sysctl --system
 
-echo 'ian  ALL=(ALL)  NOPASSWD: ALL' >> $target/etc/sudoers
+f=$target/etc/sudoers
+line='ian  ALL=(ALL)  NOPASSWD: ALL'
+if [[ ! -e $f ]] || ! grep -xF "$line" $f; then
+    echo "$line" >> $f
+fi
+
+
+dir=/q/p/c/machine_specific/$HOSTNAME/.unison
+$ROOTCMD mkdir -p $dir
+
+$ROOTCMD rm -rf /root/.unison
+$ROOTCMD ln -sf $dir /root
+$ROOTCMD ln -sf /q/p /
+
+while true; do
+    $ROOTCMD chown 1000:1000 $dir
+    $ROOTCMD chmod 700 $dir
+    dir=$(dirname $dir)
+    [[ $dir != /q ]] || break
+done
+