Changes by docelic.
[clinton/scripts.git] / hcoop-git-maint
index d148f2a..e9f20f6 100755 (executable)
@@ -7,8 +7,19 @@ 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" \;
 
+# 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" \;
+
 # Update cache of front page.
 cache=/var/local/lib/gitweb/indexcache.html
 wget -q -O $cache.tmp 'http://git.hcoop.net/?nocache=y'
-chmod a+r $cache.tmp
-mv $cache.tmp $cache
+if test -s $cache.tmp; then
+    chmod a+r $cache.tmp
+    mv $cache.tmp $cache
+else
+    rm -f $cache.tmp
+fi