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 # Latest change: Sun Oct 7 09:29:22 UTC 2007 [mika]
8 ################################################################################
12 # we want to always keep a few images, no matter how old they are
13 # but get rid of the oldest ones first of course :)
14 # so: how many images do we want to keep?
18 for flavour in grml-medium_etch grml-medium_sid grml64-medium_etch grml64-medium_sid grml64_sid grml_sid ; do
19 FILE_COUNT=$(ls -1 $flavour*.iso | wc -l)
20 if [ "$FILE_COUNT" -gt "$DAYS" ] ; then
21 FILES=$(ls -1 $flavour*.iso | tail -"$DAYS")
22 OLD_FILES=$(ls $flavour*.iso | grep -v "$FILES")
23 for file in $OLD_FILES ; do
24 REMOVE_ME="$REMOVE_ME $(find $file -mtime +$DAYS)"
29 [ -d .delete ] || mkdir .delete
31 # move them before we really delete them:
32 for file in $REMOVE_ME ; do
33 test -f ${file} && mv $file .delete
34 test -f ${file}.md5 && mv ${file}.md5 .delete
37 # inform on successful removal:
38 if [ "$(echo "$REMOVE_ME" | tr -d ' ' )" != "" ] ; then
39 echo "deleted files $REMOVE_ME" | mail -s "daily-builds cleanup script" mika@grml.org