hcoop-git-maint: Improve detection of bad permissions.
authormwolson_admin <mwolson_admin@deleuze.hcoop.net>
Wed, 1 Apr 2009 04:07:40 +0000 (00:07 -0400)
committermwolson_admin <mwolson_admin@deleuze.hcoop.net>
Wed, 1 Apr 2009 04:07:40 +0000 (00:07 -0400)
 - Fix bug where bogus symlink loop would be created.

 - Iterate through /var/cache/git on the second run, not everyone's
   homedir regardless of whether they're using git.

 - Check AFS permissions at a deeper level.  Skip object and refs
   directories because they might take a while.

hcoop-git-maint

index e9f20f6..bf4b278 100755 (executable)
@@ -4,15 +4,24 @@
 
 # Update symlinks to user git repo locations.
 find /afs/hcoop.net/user -mindepth 3 -maxdepth 3 -noleaf -exec \
-     sh -c "test -e {}/.hcoop-git && \
-         ln -s {}/.hcoop-git/ /var/cache/git/\$(basename {}) 2>/dev/null" \;
+     sh -c "test -e {}/.hcoop-git && { \
+         rm -f /var/cache/git/\$(basename {}); \
+         ln -sf {}/.hcoop-git /var/cache/git/\$(basename {}); }" \;
 
 # Remove symlinks for users that have wrong permissions
-find /afs/hcoop.net/user -mindepth 3 -maxdepth 3 -noleaf -exec \
-     sh -c "test ! -e {}/.hcoop-git || \
-         ! { fs la {}/.hcoop-git | \
-             egrep '^ +system:anyuser .*r' > /dev/null; } && \
-         rm -f /var/cache/git/\$(basename {}) 2>/dev/null" \;
+IFS=$'\n'
+for user in $(ls -1 /var/cache/git); do
+    if ! test -e $(readlink /var/cache/git/$user); then
+        rm -f /var/cache/git/$user
+        continue
+    fi
+    gitpath=$(readlink /var/cache/git/$user)
+    find -L $gitpath -noleaf -type d \
+        ! -regex '.*/\(refs\|objects\)\(/.*\|$\)' -exec \
+        sh -c "! { fs la {} | \
+                   egrep '^ +system:anyuser .*r' > /dev/null; } && \
+               rm -f /var/cache/git/$user 2>/dev/null" \;
+done
 
 # Update cache of front page.
 cache=/var/local/lib/gitweb/indexcache.html