3 # Purpose: clean up daily builds directory - remove old files
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 ################################################################################
11 . /etc/grml/grml-buildd.conf
13 [ -n "$MIRROR_DIRECTORY" ] || exit 1
14 cd $MIRROR_DIRECTORY || exit 2
16 # we want to always keep a few images, no matter how old they are
17 # but get rid of the oldest ones first of course :)
18 # so: how many images do we want to keep? DAYS=3 usually means 'keep 4 images'
22 for flavour in grml-medium_lenny grml-medium_squeeze grml-medium_sid grml-small_lenny grml-small_squeeze grml-small_sid \
23 grml64-medium_lenny grml64-medium_squeeze grml64-medium_sid grml64-small_lenny grml64-small_squeeze grml64-small_sid \
24 grml64_lenny grml64_squeeze grml64_sid grml_lenny grml_squeeze grml_sid ; do
25 FILE_COUNT=$(ls -1 $flavour/$flavour*.iso | wc -l)
26 if [ "$FILE_COUNT" -gt "$DAYS" ] ; then
27 FILES=$(ls -1 $flavour/$flavour*.iso | tail -"$DAYS")
28 OLD_FILES=$(ls $flavour/$flavour*.iso | grep -v "$FILES")
29 for file in $OLD_FILES ; do
30 REMOVE_ME="$REMOVE_ME $(find $file -mtime +$DAYS)"
35 [ -d .archive ] || mkdir .archive
37 for file in $REMOVE_ME ; do
38 test -f ${file} && rm -f $file
39 # ... but keep their md5sum / sha1sum:
40 test -f ${file}.md5 && mv ${file}.md5 .archive
41 test -f ${file}.sha1 && mv ${file}.sha1 .archive
44 # inform on successful removal:
45 if [ "$(echo "$REMOVE_ME" | tr -d ' ' )" != "" ] ; then
46 echo "deleted files $REMOVE_ME" | mail -s "daily-builds cleanup script" mika@grml.org
49 ## END OF FILE #################################################################