hcoop-git-maint: speed up and avoid blocking forever if apache is slow
authorclinton_admin <clinton_admin@navajos.hcoop.net>
Thu, 22 Oct 2015 02:24:54 +0000 (22:24 -0400)
committerclinton_admin <clinton_admin@navajos.hcoop.net>
Thu, 22 Oct 2015 02:24:54 +0000 (22:24 -0400)
Previous `find' incantation was actually scanning all the way down
objects/ and refs/. Invert the regex and actually prune. The script
runs in a few seconds rather than a good minute or two now.

Also add a wget timeout so that an unresponsive apache doesn't block
the cron job forever. The cache page isn't really used any more
anyway.

hcoop-git-maint

index e7c967f..d755f79 100755 (executable)
@@ -18,16 +18,16 @@ for user in $(ls -1 /var/cache/git); do
     fi
     gitpath=$(readlink /var/cache/git/$user)
     find -L $gitpath -noleaf -type d \
-        ! -regex '.*/\(refs\|objects\)\(/.*\|$\)' -exec \
+        -regex '.*/\(refs\|objects\|hooks\)\(/.*\|$\)' -prune -o -exec \
         sh -c "! { fs la {} | \
                    egrep '^ +system:anyuser .*r' > /dev/null; } && \
-               rm -f /var/cache/git/$user 2>/dev/null" \; \
+               rm -f /var/cache/git/$user 2>/dev/null" \; #\
         > /dev/null 2>&1
 done
 
 # Update cache of front page.
 cache=/var/local/lib/gitweb/indexcache.html
-wget -q -O $cache.tmp 'http://git.hcoop.net/?nocache=y'
+wget -q --timeout 30 -O $cache.tmp 'http://git.hcoop.net/?nocache=y'
 if test -s $cache.tmp; then
     chmod a+r $cache.tmp
     mv $cache.tmp $cache