cgal/Maintenance/test_handling/empty_dir

43 lines
996 B
Bash
Executable File

#!/bin/sh
old_results_dir=/projects/CGAL/old_results
tempdir=/tmp
while [ $# -ge 1 ]
do
if [ -d "$1" ] ; then
if [ -d "$1/Polygon" -o -d "$1/src" ] ; then
echo "emptying $1" >&2
if [ -x "$1" ] ;
then
cp -r "$1" $tempdir
find "$tempdir/$1" -name '*.gz' | xargs gunzip
(cd $tempdir; tar cf $1.tar $1; gzip --best $1.tar; rm -r $1)
if mv $tempdir/$1.tar.gz $old_results_dir
then
chgrp cgal $old_results_dir/$1.tar.gz
chmod g+w $old_results_dir/$1.tar.gz
cd $1
rm */* ;
rm -f diffs*.gz
rmdir * 2>/dev/null
cd ..
echo "Moved $1 to $old_results_dir" >&2
else
echo "Could not mv $tempdir/$1.tar.gz $old_results_dir"
fi
else
echo "Could not cd to $1" >&2
fi
else
echo "$1 seems to be emptied already" >&2
fi
else
echo "$1 is not a directory" >&2
fi
shift
done