mostly refactor mail-setup, more self contained
[distro-setup] / conflink
index 8431c168a40a5a36e13d7a2fd17ba80f39f1dbf5..948d1a22694b89aa08b4b984b20b7f494713bb4c 100755 (executable)
--- a/conflink
+++ b/conflink
@@ -43,18 +43,38 @@ subdir-link-r() {
     done
 }
 
+
+
 common-file-setup() {
-    local dir fs x
+    local dir fs x bdir f dst
     for dir in "$@"; do
         fs=$dir/filesystem
         if [[ -e $fs && $USER == ian ]]; then
             # note, symlinks get resolved, not copied.
             m s cp -RLT --preserve=mode,timestamps $fs /
         fi
+
+        # one program so far does not work with a symlink,
+        # so we have to use a bind mount
+        bdir=$dir/binds
+        if [[ -e $bdir && $USER == ian ]]; then
+            for f in $(find $bdir -type f); do
+                dst=/home/ian/${f##$bdir}
+                if [[ ! -e $dst || $(stat -c%i $f $dst |uniq -u) ]]; then
+                    if mountpoint -q $dst; then
+                        s umount $dst
+                    fi
+                    # note: in future, may need to mkdir also
+                    [[ -e $dst ]] || touch $dst
+                    s mount --bind $f $dst
+                fi
+            done
+        fi
+
         if [[ -e $dir/subdir_files ]]; then
             subdir-link-r $dir/subdir_files
         fi
-        local x=( $dir/!(subdir_files|filesystem|machine_specific|..|.) )
+        local x=( $dir/!(binds|subdir_files|filesystem|machine_specific|..|.) )
         (( ${#x[@]} >= 1 )) || continue
         m lnf ${x[@]} ~
     done