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