Skip to content
Snippets Groups Projects
Commit ca2f4c56 authored by david_williams's avatar david_williams
Browse files

improve daily cleanup scripts

parent e2c12572
No related branches found
No related tags found
No related merge requests found
...@@ -164,19 +164,19 @@ echo; ...@@ -164,19 +164,19 @@ echo;
# artifacts are special, since they have a three-layer directory structure, # artifacts are special, since they have a three-layer directory structure,
# and we want to be sure to always retain at least one, no matter how old. # and we want to be sure to always retain at least one, no matter how old.
echo; echo " ";
echo "INFO: Checking to remove old artifacts." echo "INFO: Checking to remove old artifacts."
removeOldArtifactsDirectories ${PROJECT_ARTIFACTS} 3 1; removeOldArtifactsDirectories ${PROJECT_ARTIFACTS} 3 1;
echo; echo " ";
echo "INFO: Checking to remove old project working directories." echo "INFO: Checking to remove old project working directories."
removeOldDirectories ${PROJECT_PROJECTS} 0; removeOldDirectories ${PROJECT_PROJECTS} 0;
echo; echo " ";
echo "INFO: Checking to remove old testing directories." echo "INFO: Checking to remove old testing directories."
removeOldDirectories ${PROJECT_TESTS} 0; removeOldDirectories ${PROJECT_TESTS} 0;
echo; echo " ";
echo "INFO: Checking to remove old tmp directories and files." echo "INFO: Checking to remove old tmp directories and files."
removeOldDirectoriesAndFiles ${RECOMMENDED_TMP_DIR} 13; removeOldDirectoriesAndFiles ${RECOMMENDED_TMP_DIR} 13;
...@@ -190,11 +190,11 @@ removeOldDirectoriesAndFiles ${RECOMMENDED_TMP_DIR} 13; ...@@ -190,11 +190,11 @@ removeOldDirectoriesAndFiles ${RECOMMENDED_TMP_DIR} 13;
# autodownload so when if/when we want it, we have to get our selves, and copy into prereqs directory. # 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, # 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. # once unzipped, so we have tweeked the permissions.
echo; echo " ";
echo "INFO: Checking to remove old pre-req directories and files not accessed for 3 months." echo "INFO: Checking to remove old pre-req directories and files not accessed for 3 months.";
removeOldDirectoriesAndFiles ${LOCAL_PREREQS_CACHE} 90; removeOldDirectoriesAndFiles ${LOCAL_PREREQS_CACHE} 90;
echo; echo " ";
echo "INFO: Checking to remove old basebuilders not accessed for 3 months." echo "INFO: Checking to remove old basebuilders not accessed for 3 months.";
removeOldDirectories ${BASE_BUILDERS} 90; removeOldDirectories ${BASE_BUILDERS} 90;
...@@ -5,29 +5,30 @@ function removeIf () ...@@ -5,29 +5,30 @@ function removeIf ()
{ {
# echo "arg: $1"; # echo "arg: $1";
if [ -z $1 ] foundDirectory=$1
if [ -z "${foundDirectory}" ]
then then
echo "ERROR: No argument. This function requires a directory as an argument. " ; echo "ERROR: No argument. This function requires a directory as an argument. " ;
return 1; return 1;
fi fi
foundDirectory=$1
if [ ! -d $foundDirectory ] if [ ! \( -d "${foundDirectory}" \) ]
then then
echo "ERROR: " "${foundDirectory}" ", is not a directory. This function requires a directory as an argument. " echo "ERROR: " "${foundDirectory}" ", is not a directory. This function requires a directory as an argument. "
return 2; return 2;
fi fi
# should already be in foundDirectory, if execDir used (and execDir, in a 'find' is recommended, as more secure) # should already be in foundDirectory, if execDir used (and execDir, in a 'find' is recommended, as more secure)
cd $foundDirectory #cd $foundDirectory
rm -fr $foundDirectory rm -fr "${foundDirectory}"
rcode=$? rcode=$?
if [ $rcode -eq 0 ] if [ $rcode -eq 0 ]
then then
echo " removed: $foundDirectory"; echo " removed: "${foundDirectory}";
else else
echo "WARNING: rm returned non zero return code: " $rccode ". could not remove " $foundDirectory; echo "WARNING: rm returned non zero return code: " $rccode ". could not remove " "${foundDirectory}";
fi fi
return $rcode; return $rcode;
...@@ -57,11 +58,10 @@ function removeArtifactsDirIf () ...@@ -57,11 +58,10 @@ function removeArtifactsDirIf ()
return 2; return 2;
fi fi
# should already be in foundDirectory, if execDir used (and execDir, in a 'find' is recommended, as more secure) # should already be in appropriate directory, if execDir in 'find' is used (and execDir, in a 'find' is recommended, as more secure)
cd $foundDirectory # cd "${foundDirectory}"
# move up one so we can examine syblings # move up one so we can examine syblings
cd .. #cd ..
currentDirectory=`pwd` currentDirectory=`pwd`
echo " current working directory: $currentDirectory"; echo " current working directory: $currentDirectory";
ndirs=`ls -lA | wc -l` ndirs=`ls -lA | wc -l`
...@@ -81,13 +81,13 @@ function removeArtifactsDirIf () ...@@ -81,13 +81,13 @@ function removeArtifactsDirIf ()
exit 101; exit 101;
fi fi
rm -fr $foundDirectory rm -fr "${foundDirectory}"
rcode=$? rcode=$?
if [ $rcode -eq 0 ] if [ $rcode -eq 0 ]
then then
echo " removed: $foundDirectory"; echo " removed: "${foundDirectory}"";
else else
echo "WARNING: rm returned non zero return code: " $rccode ". could not remove " $foundDirectory; echo "WARNING: rm returned non zero return code: " $rccode ". could not remove " "${foundDirectory}";
fi fi
return $rcode; return $rcode;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment