fix cleanup script

This commit is contained in:
abejgonzalez 2019-07-09 23:42:04 -07:00
parent 82e7814205
commit fdf0edf8e0
3 changed files with 6 additions and 7 deletions

View File

@ -12,7 +12,7 @@ source $SCRIPT_DIR/defaults.sh
# call clean on exit
trap clean EXIT
run_script $LOCAL_CHIPYARD_DIR/.circleci/clean-old-files.sh
run_script $LOCAL_CHIPYARD_DIR/.circleci/clean-old-files.sh $CI_DIR
if [ ! -d "$LOCAL_VERILATOR_DIR" ]; then
# set stricthostkeychecking to no (must happen before rsync)

View File

@ -1,10 +1,7 @@
#!/bin/bash
# clean directories that are older than 30 days
# get shared variables
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
source $SCRIPT_DIR/defaults.sh
# argument is used as the directory to look in
age () {
local AGE_SEC
@ -21,10 +18,12 @@ age () {
echo $(expr $DIFF_SEC / $SEC_PER_DAY)
}
for d in $CI_DIR/*/ ; do
for d in $1/*/ ; do
DIR_AGE="$(age $d)"
if [ $DIR_AGE -ge 30 ]; then
echo "Deleting $d since is it $DIR_AGE old"
rm -rf $d
else
echo "Keep $d since it is $DIR_AGE old"
fi
done

View File

@ -9,7 +9,7 @@ run () {
}
run_script () {
ssh -o "StrictHostKeyChecking no" -t $SERVER 'bash -s' < $1
ssh -o "StrictHostKeyChecking no" -t $SERVER 'bash -s' < $1 "$2"
}
clean () {