fix running for traci homedir
authorIan Kelling <ian@iankelling.org>
Fri, 13 May 2016 06:15:30 +0000 (23:15 -0700)
committerIan Kelling <ian@iankelling.org>
Fri, 13 May 2016 06:15:30 +0000 (23:15 -0700)
conflink

index e263e0687d7aebd0bcf3663c760ca4bd2a92f8d7..a4a32da01c1b92c51f2da5ba3bf1d22fa843965b 100755 (executable)
--- a/conflink
+++ b/conflink
@@ -32,14 +32,7 @@ subdir-link-r() {
         local fullpath="$(readlink -f "$path")"
         #e $fullpath $below # debug
         if [[ -f $path || $(dirname $(readlink -f "$fullpath")) == "$below" ]]; then
-            if [[ $dir == /p/* ]]; then
-                homes=(/home/ian)
-            else
-                homes=(/home/*)
-            fi
-            for user in ${homes[@]}; do
-                sysv lnf -T "$path" "$user/${path#$root/}"
-            done
+            sysv lnf -T "$path" "$HOME/${path#$root/}"
         elif [[ -d "$path" ]]; then
             subdir-link-r "$root" "$path"
         fi
@@ -54,12 +47,26 @@ common-file-setup() {
     (( ${#x[@]} >= 1 )) || return 0
     sysv lnf ${x[@]} ~
     # as of this writing, it doesn't exist in /a/c, but I've used it in the past.
-    if [[ -e $1/filesystem ]]; then
+    if [[ -e $1/filesystem && $USER == ian ]]; then
         sysv s cp -R $1/filesystem/* /
     fi
 }
 
-# p needs to go first so .ssh link is created, then config link inside it
-for dir in {/a/c,/p/c}{,/machine_specific/$HOSTNAME}; do
-    common-file-setup $dir
-done
+case $USER in
+    ian)
+        # p needs to go first so .ssh link is created, then config link inside it
+        for dir in {/a/c,/p/c}{,/machine_specific/$HOSTNAME}; do
+            common-file-setup $dir
+        done
+        sudo -u traci "$BASH_SOURCE"
+        ;;
+    traci)
+        for dir in /a/c{,/machine_specific/$HOSTNAME}; do
+            common-file-setup $dir
+        done
+        ;;
+    *)
+        echo "$0: error: run as ian or traci"
+        exit 1
+        ;;
+esac