]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.weekly
path changes
[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 # Vacuum the database
39 echo "VACUUM; VACUUM ANALYZE;" | psql --no-psqlrc projectb 2>&1
40
41 # Do git cleanup stuff
42 echo "Doing git stuff"
43 cd /org/ftp.debian.org/git/dak.git
44 git gc --prune
45 git update-server-info
46 # now workaround a git bug not honoring the setup in logs/*
47 # (fix in development, but until it reached backports.org.......)
48 chmod -R g+w logs/
49
50 # Clean up apt-ftparchive's databases
51 cd $configdir
52 echo "Cleanup apt-ftparchive's database"
53 apt-ftparchive -q clean apt.conf
54 apt-ftparchive -q clean apt.conf.buildd
55
56 # Update wanna-build dump
57 echo "Update wanna-build database dump"
58 /org/ftp.debian.org/scripts/nfu/get-w-b-db
59
60 echo "Fixing symlinks in $ftpdir"
61 symlinks -d -r $ftpdir
62
63 echo "Finally, all is done, compressing logfile"
64 exec > /dev/null 2>&1
65
66 bzip2 -9 "$LOGFILE"
67
68
69 ################################################################################