X-Git-Url: http://git.hcoop.net/hcoop/scripts.git/blobdiff_plain/f4189f51de6a481c92f181303a27e0c0ef64f2af..abfe84ca1bf183ef33ee25ac66820a2e256cb520:/hcoop-git-maint diff --git a/hcoop-git-maint b/hcoop-git-maint index 327ff88..e7c967f 100755 --- a/hcoop-git-maint +++ b/hcoop-git-maint @@ -4,11 +4,33 @@ # 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 {}); }" \; \ + > /dev/null 2>&1 + +# Remove symlinks for users that have wrong permissions +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" \; \ + > /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/test?nocache=y' -chmod a+r $cache.tmp -mv $cache.tmp $cache +wget -q -O $cache.tmp 'http://git.hcoop.net/?nocache=y' +if test -s $cache.tmp; then + chmod a+r $cache.tmp + mv $cache.tmp $cache +else + rm -f $cache.tmp +fi