cron.weekly 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. #
  3. # Run once a week via cron, out of dak's crontab.
  4. set -e
  5. set -o pipefail
  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. # Start logging
  14. NOW=`date "+%Y.%m.%d-%H:%M:%S"`
  15. LOGFILE="$logdir/weekly_${NOW}.log"
  16. exec > "$LOGFILE" 2>&1
  17. cleanup() {
  18. echo "Cleanup"
  19. rm -f "$LOGFILE"
  20. }
  21. trap cleanup 0
  22. ################################################################################
  23. # Purge empty directories
  24. echo "Purging empty directories in $ftpdir/pool/"
  25. if [ ! -z "$(find $ftpdir/pool/ -type d -empty)" ]; then
  26. find $ftpdir/pool/ -type d -empty | xargs rmdir;
  27. fi
  28. # Do git cleanup stuff
  29. echo "Doing git stuff"
  30. cd /srv/ftp.debian.org/git/dak.git
  31. git gc --prune
  32. git update-server-info
  33. # now workaround a git bug not honoring the setup in logs/*
  34. # (fix in development, but until it reached backports.org.......)
  35. chmod -R g+w logs/
  36. echo "Fixing symlinks in $ftpdir"
  37. symlinks -d -r $ftpdir
  38. echo "Finally, all is done, compressing logfile"
  39. exec > /dev/null 2>&1
  40. bzip2 -9 "$LOGFILE"
  41. ################################################################################