improve daily cleanup scripts
diff --git a/releng.control/cleanupArtifacts.sh b/releng.control/cleanupArtifacts.sh
index f2318d5..d5b7110 100644
--- a/releng.control/cleanupArtifacts.sh
+++ b/releng.control/cleanupArtifacts.sh
@@ -186,9 +186,9 @@
# autodownload so when if/when we want it, we have to get our selves, and copy into prereqs directory.
# And one of those, I think oagis_release? has some write protected files that prevents their deletion,
# once unzipped, so we have tweeked the permissions.
-echo "INFO: Checking to remove old pre-req directories and files not accessed for 1 month."
-removeOldDirectoriesAndFiles ${LOCAL_PREREQS_CACHE} 30;
+echo "INFO: Checking to remove old pre-req directories and files not accessed for 3 months."
+removeOldDirectoriesAndFiles ${LOCAL_PREREQS_CACHE} 90;
-echo "INFO: Checking to remove old pre-req directories and files not accessed for 1 month."
-removeOldDirectories ${BASE_BUILDERS} 30;
+echo "INFO: Checking to remove old basebuilders not accessed for 3 months."
+removeOldDirectories ${BASE_BUILDERS} 90;
diff --git a/releng.control/removeArtifactDirIf.sh b/releng.control/removeArtifactDirIf.sh
new file mode 100644
index 0000000..046437f
--- /dev/null
+++ b/releng.control/removeArtifactDirIf.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+source removeUtils.shsource
+
+return removeArtifactsDirIf "$*"
diff --git a/releng.control/removeIf.sh b/releng.control/removeIf.sh
new file mode 100644
index 0000000..4d83fc4
--- /dev/null
+++ b/releng.control/removeIf.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+source removeUtils.shsource
+
+return removeIf "$*"
diff --git a/releng.control/removeUtils.shsource b/releng.control/removeUtils.shsource
new file mode 100644
index 0000000..508718a
--- /dev/null
+++ b/releng.control/removeUtils.shsource
@@ -0,0 +1,95 @@
+#!/usr/bin/env bash
+
+# simple function that can be called via 'find' that removes and displays name of removed directory
+function removeIf ()
+{
+ # echo "arg: $1";
+
+ if [ -z $1 ]
+ then
+ echo "ERROR: No argument. This function requires a directory as an argument. " ;
+ return 1;
+ fi
+ foundDirectory=$1
+
+ if [ ! -d $foundDirectory ]
+ then
+ echo "ERROR: " "${foundDirectory}" ", is not a directory. This function requires a directory as an argument. "
+ return 2;
+ fi
+
+ # should already be in foundDirectory, if execDir used (and execDir, in a 'find' is recommended, as more secure)
+ cd $foundDirectory
+
+ rm -fr $foundDirectory
+ rc=$?
+ if [ rc == 0 ]
+ then
+ echo " removed: $foundDirectory";
+ else
+ echo "WARNING: rc: " $rc " could not remove " $foundDirectory;
+ fi
+
+ return rc;
+}
+
+# function that can remove a directory (e.g. via find) but checks to make sure not to remove the last one (or, last 'saveAtLeast')
+function removeArtifactsIf ()
+{
+ # echo "arg: $1";
+
+ if [ -z $1 ]
+ then
+ echo "ERROR: No argument. This function requires a directory as an argument. " ;
+ return 1;
+ fi
+ foundDirectory=$1
+ nSave=$2
+
+ if [ -z $nSave ]
+ then
+ nSave=1;
+ fi
+
+ if [ ! -d $foundDirectory ]
+ then
+ echo "ERROR: " "${foundDirectory}" ", is not a directory. This function requires a directory as an argument. "
+ return 2;
+ fi
+
+ # should already be in foundDirectory, if execDir used (and execDir, in a 'find' is recommended, as more secure)
+ cd $foundDirectory
+
+ # move up one so we can examine syblings
+ cd ..
+ currentDirectory=`pwd`
+ echo " current working directory: $currentDirectory";
+ ndirs=`ls -lA | wc -l`
+ ndirs=$(($ndirs - 1)); # don't count the "totals" line
+ # echo "NDirs: $ndirs"
+
+ # if only one left, do not remove it, no matter how old
+ # or, as improved ... if less than or equal to nSave is left, do not remove
+ if [ $ndirs -le $nSave ]
+ then
+ return 0;
+ fi
+ # To have no directories is unexpected, since otherwise this method should not have been called.
+ # So, this check is just a safety check.
+ if [ $ndirs -lt 1 ]
+ then
+ exit 101;
+ fi
+
+ rm -fr $foundDirectory
+ rc=$?
+ if [ rc == 0 ]
+ then
+ echo " removed: $foundDirectory";
+ else
+ echo "WARNING: rc: " $rc ". could not remove " $foundDirectory;
+ fi
+
+ return rc;
+
+}