]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.weekly
7d884b6a1e707a07f9afb1eb5378b1cc8f0db933
[dak.git] / config / debian / cron.weekly
1 #!/bin/bash
2 #
3 # Run once a week via cron, out of dak's crontab.
4
5 set -e
6 set -o pipefail
7 set -u
8 # ERR traps should be inherited from functions too. (And command
9 # substitutions and subshells and whatnot, but for us the functions is
10 # the important part here)
11 set -E
12 export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
13 . $SCRIPTVARS
14
15 # Start logging
16 NOW=`date "+%Y.%m.%d-%H:%M:%S"`
17 LOGFILE="$logdir/weekly_${NOW}.log"
18 exec > "$LOGFILE" 2>&1
19
20 cleanup() {
21   echo "Cleanup"
22   rm -f "$LOGFILE"
23 }
24 trap cleanup 0
25
26 ################################################################################
27
28 # Purge empty directories
29 echo "Purging empty directories in $ftpdir/pool/"
30
31 if [ ! -z "$(find $ftpdir/pool/ -type d -empty)" ]; then
32    find $ftpdir/pool/ -type d -empty | xargs rmdir;
33 fi
34
35 # Do git cleanup stuff
36 echo "Doing git stuff"
37 cd /srv/ftp.debian.org/git/dak.git
38 git gc --prune
39 git update-server-info
40 # now workaround a git bug not honoring the setup in logs/*
41 # (fix in development, but until it reached backports.org.......)
42 chmod -R g+w logs/
43
44 echo "Fixing symlinks in $ftpdir"
45 symlinks -d -r $ftpdir
46
47 echo "Finally, all is done, compressing logfile"
48 exec > /dev/null 2>&1
49
50 bzip2 -9 "$LOGFILE"
51
52
53 ################################################################################