f4189f51 |
1 | #!/bin/bash |
2 | # |
3 | # Git maintenance script, run by cron. |
4 | |
5 | # Update symlinks to user git repo locations. |
6 | find /afs/hcoop.net/user -mindepth 3 -maxdepth 3 -noleaf -exec \ |
294904cc |
7 | sh -c "test -e {}/.hcoop-git && { \ |
8 | rm -f /var/cache/git/\$(basename {}); \ |
9 | ln -sf {}/.hcoop-git /var/cache/git/\$(basename {}); }" \; |
f4189f51 |
10 | |
3b680833 |
11 | # Remove symlinks for users that have wrong permissions |
294904cc |
12 | IFS=$'\n' |
13 | for user in $(ls -1 /var/cache/git); do |
14 | if ! test -e $(readlink /var/cache/git/$user); then |
15 | rm -f /var/cache/git/$user |
16 | continue |
17 | fi |
18 | gitpath=$(readlink /var/cache/git/$user) |
19 | find -L $gitpath -noleaf -type d \ |
20 | ! -regex '.*/\(refs\|objects\)\(/.*\|$\)' -exec \ |
21 | sh -c "! { fs la {} | \ |
22 | egrep '^ +system:anyuser .*r' > /dev/null; } && \ |
23 | rm -f /var/cache/git/$user 2>/dev/null" \; |
24 | done |
3b680833 |
25 | |
f4189f51 |
26 | # Update cache of front page. |
27 | cache=/var/local/lib/gitweb/indexcache.html |
df1962e3 |
28 | wget -q -O $cache.tmp 'http://git.hcoop.net/?nocache=y' |
863f93ee |
29 | if test -s $cache.tmp; then |
30 | chmod a+r $cache.tmp |
31 | mv $cache.tmp $cache |
32 | else |
33 | rm -f $cache.tmp |
34 | fi |