]> git.decadent.org.uk Git - dak.git/blob - config/backports/cron.weekly
fcdffb029e7ea3ce34ab188dae621d5f704df329
[dak.git] / config / backports / cron.weekly
1 #!/bin/bash
2 #
3
4 set -e
5 set -u
6 # ERR traps should be inherited from functions too. (And command
7 # substitutions and subshells and whatnot, but for us the functions is
8 # the important part here)
9 set -E
10 export SCRIPTVARS=/srv/backports-master.debian.org/dak/config/backports/vars
11 . $SCRIPTVARS
12
13 # Start logging
14 NOW=`date "+%Y.%m.%d-%H:%M:%S"`
15 LOGFILE="$logdir/weekly_${NOW}.log"
16 exec > "$LOGFILE" 2>&1
17
18 cleanup() {
19   echo "Cleanup"
20   rm -f "$LOGFILE"
21 }
22 trap cleanup 0
23
24 ################################################################################
25
26 # Purge empty directories
27 echo "Purging empty directories in $ftpdir/pool/"
28 if [ ! -z "$(find $ftpdir/pool/ -type d -empty)" ]; then
29    find $ftpdir/pool/ -type d -empty | xargs rmdir;
30 fi
31
32 # Clean up apt-ftparchive's databases
33
34 echo "Splitting queue/done"
35 dak split-done
36
37 # Clean up apt-ftparchive's databases
38 cd $configdir
39 echo "Cleanup apt-ftparchive's database"
40 apt-ftparchive -q clean apt.conf
41
42 echo "Fixing symlinks in $ftpdir"
43 symlinks -d -r $ftpdir
44
45 echo "Finally, all is done, compressing logfile"
46 exec > /dev/null 2>&1
47
48 bzip2 -9 "$LOGFILE"
49
50
51 ################################################################################