From 7f92f0fd959aba87e6223dd818ecd8d648e041c2 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Mon, 9 Jul 2012 18:49:52 +0200 Subject: [PATCH] cleanold daily cron: clean old files in all autoport configured environments --- etc/cron.daily/40-openmamba-autodist-cleanold | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/etc/cron.daily/40-openmamba-autodist-cleanold b/etc/cron.daily/40-openmamba-autodist-cleanold index 7ea85f2..0c0e616 100755 --- a/etc/cron.daily/40-openmamba-autodist-cleanold +++ b/etc/cron.daily/40-openmamba-autodist-cleanold @@ -1,7 +1,27 @@ #!/bin/bash -find /var/autodist/RPM/RPMS/i586/ -maxdepth 1 -ctime +25 -exec rm -rf {} \; -find /var/autodist/RPM/RPMS/noarch/ -maxdepth 1 -ctime +25 -exec rm -rf {} \; -find /var/autodist/RPM/BUILD/ -maxdepth 1 -ctime +25 -exec rm -rf {} \; -find /var/autodist/RPM/SOURCES/ -maxdepth 1 -ctime +120 -exec rm -rf {} \; -find /var/autodist/RPM/SRPMS/ -maxdepth 1 -ctime +90 -exec rm -rf {} \; -find /var/tmp/autodist/ -maxdepth 1 -ctime +25 -exec rm -rf {} \; +[ -e /etc/sysconfig/autoport ] && . /etc/sysconfig/autoport + +function clean() { + dir=$1 + arch=$2 + find $dir/RPM/RPMS/$arch/ -maxdepth 1 -ctime +30 -exec rm -rf {} \; + find $dir/RPM/RPMS/noarch/ -maxdepth 1 -ctime +30 -exec rm -rf {} \; + find $dir/RPM/BUILD/ -maxdepth 1 -ctime +30 -exec rm -rf {} \; + find $dir/RPM/SOURCES/ -maxdepth 1 -ctime +120 -exec rm -rf {} \; + find $dir/RPM/SRPMS/ -maxdepth 1 -ctime +90 -exec rm -rf {} \; +} + +for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do + if [ "${AUTOPORT_CHROOT[$i]}" ]; then + a=${AUTOPORT_CHROOT[$i]} + clean /var/autoport/$a/usr/src ${AUTOPORT_ARCH[$i]} + [ -e /var/autoport/$a/var/autodist/RPM/RPMS/$arch ] && \ + clean /var/autoport/$a/var/autodist ${AUTOPORT_ARCH[$i]} + [ -e /var/autoport/$a/var/tmp/autodist ] && \ + find /var/autoport/$a/var/tmp/autodist/ -maxdepth 1 -ctime +25 -exec rm -rf {} \; + find /var/autoport/$a/tmp/ -maxdepth 1 -ctime +25 -exec rm -rf {} \; + elif [ "${AUTOPORT_UPDATE[$i]}" ]; then + clean /var/autodist ${AUTOPORT_ARCH[$i]} + find /var/tmp/autodist/ -maxdepth 1 -ctime +25 -exec rm -rf {} \; + fi +done