X-Git-Url: https://git.grml.org/?p=grml-live.git;a=blobdiff_plain;f=buildd%2Fcleanup.sh;h=d0e6fe7c36006eb56ab9e01e56c4c4f5a38e12d4;hp=79c1223cea701ee5a80f6fdf43b1ddd5429b928c;hb=6d5124d02e3912ac0ca53c0f0af92ef9ebceae23;hpb=328682f98d399e1f24ae7729ec740e56ef6f6257 diff --git a/buildd/cleanup.sh b/buildd/cleanup.sh index 79c1223..d0e6fe7 100755 --- a/buildd/cleanup.sh +++ b/buildd/cleanup.sh @@ -4,39 +4,66 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2 or any later version. -# Latest change: Sun Oct 7 09:29:22 UTC 2007 [mika] ################################################################################ set -e +dir="$(dirname $0)" + +if [ -r /etc/grml/grml-buildd.conf ] ; then + . /etc/grml/grml-buildd.conf +elif [ -r "${dir}/grml-buildd.conf" ] ; then + . "${dir}/grml-buildd.conf" +fi + +# directory where daily ISOs are stored locally +if [ -z "$MIRROR_DIRECTORY" ] ; then + echo "Error: \$MIRROR_DIRECTORY is not set. Exiting." >&2 + exit 1 +fi + +# mail address where reports should be sent to +if [ -z "$STORAGE_ADMIN" ] ; then + echo "Error: \$STORAGE_ADMIN is not set. Exiting." >&2 + exit 2 +fi + +if ! cd "$MIRROR_DIRECTORY" ; then + echo "Error: could not change directory to $MIRROR_DIRECTORY" >&2 + exit 3 +fi + # we want to always keep a few images, no matter how old they are # but get rid of the oldest ones first of course :) -# so: how many images do we want to keep? +# so: how many images do we want to keep? DAYS=3 usually means 'keep 4 images' DAYS=3 REMOVE_ME="" -for flavour in grml-medium_etch grml-medium_sid grml64-medium_etch grml64-medium_sid grml64_sid grml_sid ; do - FILE_COUNT=$(ls -1 $flavour*.iso | wc -l) +for flavour in grml-medium_squeeze grml-medium_wheezy grml-medium_sid grml-small_squeeze grml-small_wheezy grml-small_sid \ + grml64-medium_squeeze grml64-medium_wheezy grml64-medium_sid grml64-small_squeeze grml64-small_wheezy grml64-small_sid \ + grml64_squeeze grml64_wheezy grml64_sid grml_squeeze grml_wheezy grml_sid ; do + FILE_COUNT=$(ls -1 $flavour/$flavour*.iso | wc -l) if [ "$FILE_COUNT" -gt "$DAYS" ] ; then - FILES=$(ls -1 $flavour*.iso | tail -"$DAYS") - OLD_FILES=$(ls $flavour*.iso | grep -v "$FILES") + FILES=$(ls -1 $flavour/$flavour*.iso | tail -"$DAYS") + OLD_FILES=$(ls $flavour/$flavour*.iso | grep -v "$FILES") for file in $OLD_FILES ; do REMOVE_ME="$REMOVE_ME $(find $file -mtime +$DAYS)" done fi done -[ -d .delete ] || mkdir .delete +[ -d .archive ] || mkdir .archive -# move them before we really delete them: for file in $REMOVE_ME ; do - test -f ${file} && mv $file .delete - test -f ${file}.md5 && mv ${file}.md5 .delete + test -f ${file} && rm -f $file + # ... but keep their md5sum / sha1sum: + test -f ${file}.md5 && mv ${file}.md5 .archive + test -f ${file}.sha1 && mv ${file}.sha1 .archive done # inform on successful removal: if [ "$(echo "$REMOVE_ME" | tr -d ' ' )" != "" ] ; then - echo "deleted files $REMOVE_ME" | mail -s "daily-builds cleanup script" mika@grml.org + echo "deleted files $REMOVE_ME" | mail -s "daily-builds cleanup script" "$STORAGE_ADMIN" fi -# EOF +## END OF FILE #################################################################