makedist-autobuild-cleanold: added cron script for automatic cleaning of older autobuilds
This commit is contained in:
parent
974c30e94b
commit
1863bedc32
1
Makefile
1
Makefile
@ -76,6 +76,7 @@ install: install-locales
|
||||
cp -a config/makedist $(DESTDIR)$(sysconfdir)/sysconfig/makedist;\
|
||||
install -d $(DESTDIR)$(sysconfdir)/cron.daily;\
|
||||
cp -a config/20-makedist-autobuild $(DESTDIR)$(sysconfdir)/cron.daily/20-makedist-autobuild;\
|
||||
cp -a config/30-makedist-autobuild-cleanold $(DESTDIR)$(sysconfdir)/cron.daily/30-makedist-autobuild-cleanold;\
|
||||
install -d $(DESTDIR)$($recordvmstatedir);\
|
||||
cp -a var/recordvm-xinitrc $(DESTDIR)$(recordvmstatedir)/.xinitrc;\
|
||||
cp -a var/recordvm-xvidcaprc $(DESTDIR)$(recordvmstatedir)/.xvidcaprc;\
|
||||
|
66
config/30-makedist-autobuild-cleanold
Executable file
66
config/30-makedist-autobuild-cleanold
Executable file
@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Makedist automatic clean script
|
||||
# Copyright (c) 2007-2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
. /etc/sysconfig/makedist
|
||||
SOURCEDIR=/var/makedist
|
||||
DESTBASEDIR=/var/ftp/pub/openmamba/devel/media
|
||||
DESTBASEURL=/pub/openmamba/devel/media
|
||||
[ "$TODAYDATE" ] || TODAYDATE=`date +%Y%m%d`
|
||||
GLOBDOWNLOADSFILE=$DESTBASEDIR/downloads.inc
|
||||
LANGS="it en es"
|
||||
ARCHS="i586 arm"
|
||||
|
||||
tmpfile=`mktemp`
|
||||
|
||||
[ $tmpfile ] || {
|
||||
echo "Error: cannot create temporary files; aborting."
|
||||
exit 1
|
||||
}
|
||||
for l in $LANGS; do
|
||||
for d in `find $DESTBASEDIR/*/$l -maxdepth 0 -type d`; do
|
||||
for a in $ARCHS; do
|
||||
> $tmpfile
|
||||
for f in `find $d -maxdepth 1 -name "*.$a.iso" -o -name "*.$a.cpio.gz" -o -name "*.$a.tar.gz" -o -name "*.$a.tar.xz" -o -name "*.$a.tar.bz2"`; do
|
||||
echo `stat -c %Z $f` `basename $f` >> $tmpfile
|
||||
done
|
||||
filecount=0
|
||||
for f in `cat $tmpfile | sort -r | awk '{ print $2 }' `; do
|
||||
if [ $filecount = 0 ]; then
|
||||
[ "$VERBOSE" -o "$SIMULATE" ] && echo "KEEP $f"
|
||||
else
|
||||
[ "$VERBOSE" -o "$SIMULATE" ] && echo "MOVE $f"
|
||||
[ "$SIMULATE" ] && continue
|
||||
[ -e $d/old ] || mkdir -p $d/old
|
||||
mv $d/$f $d/old/
|
||||
[ -e $d/$f.MD5.txt ] && mv $d/$f.MD5.txt $d/old/
|
||||
[ -e $d/$f.torrent ] && mv $d/$f.torrent $d/old/
|
||||
fi
|
||||
filecount=`expr $filecount + 1`
|
||||
done
|
||||
# clean old directory
|
||||
> $tmpfile
|
||||
for f in `find $d/old -maxdepth 1 -name "*.$a.iso" -o -name "*.$a.cpio.gz" -o -name "*.$a.tar.gz" -o -name "*.$a.tar.xz" -o -name "*.$a.tar.bz2"`; do
|
||||
echo `stat -c %Z $f` `basename $f` >> $tmpfile
|
||||
done
|
||||
SNAPSHOT_DATE=
|
||||
for f in `cat $tmpfile | sort -r | awk '{ print $2 }' `; do
|
||||
SNAPSHOT_DATE_PREVIOUS=$SNAPSHOT_DATE
|
||||
SNAPSHOT_DATE=`echo $f | sed "s|.*snapshot-\([0-9]*\)\..*|\1|"`
|
||||
if [ "${SNAPSHOT_DATE:0:6}" = "${SNAPSHOT_DATE_PREVIOUS:0:6}" ]; then
|
||||
[ "$VERBOSE" -o "$SIMULATE" ] && echo "DELE old/$f ($SNAPSHOT_DATE)"
|
||||
[ "$SIMULATE" ] && continue
|
||||
rm -f $d/old/$f
|
||||
[ -e $d/old/$f.MD5.txt ] && rm -f $d/old/$f.MD5.txt
|
||||
[ -e $d/old/$f.torrent ] && rm -f $d/old/$f.torrent
|
||||
else
|
||||
[ "$VERBOSE" -o "$SIMULATE" ] && echo "KEEP old/$f ($SNAPSHOT_DATE)"
|
||||
fi
|
||||
done
|
||||
done
|
||||
# echo
|
||||
# ls --sort=time $d/*.iso $d/*.cpio.gz
|
||||
#find $DESTBASEDIR -name *.iso
|
||||
done
|
||||
done
|
Loading…
Reference in New Issue
Block a user