]> git.ipfire.org Git - people/ms/nightly-builds.git/commitdiff
cleanup: Keep 2 builds per branch
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 2 Nov 2015 11:28:44 +0000 (12:28 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 2 Nov 2015 11:28:44 +0000 (12:28 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
server-scripts/ipfire-cleanup-nightly-builds.sh

index 3abe283622e538283d7eff214ff5d438c8fa01cf..cd65a9548779d667d498b055b07a23945d7a3882 100755 (executable)
@@ -6,25 +6,28 @@ MAX_AGE=$(( 7 * 24 * 3600 )) # 7 days
 
 NOW="$(date +"%s")"
 
-counter=0
-for build in $(find "${BASEDIR}" -mindepth 2 -maxdepth 2 -type d | sort -nr); do
-       time="$(basename "${build}")"
-       [ "${time}" = "latest" ] && continue
-
-       # Never delete the last two builds
-       if [ "${counter}" -lt 2 ]; then
-               counter=$(( ${counter} + 1 ))
-               continue
-       fi
-
-       # Determine age of the build
-       change="$(stat --format="%Y" "${build}")"
-       age=$(( ${NOW} - ${change} ))
-
-       # If the build is old enough we will delete it
-       if [[ ${age} -ge ${MAX_AGE} ]]; then
-               rm -rf "${build}"
-       fi
+for branch in $(find "${BASEDIR}" -mindepth 1 -maxdepth 1 -type d); do
+       counter=0
+
+       for build in $(find "${branch}" -mindepth 1 -maxdepth 1 -type d | sort -nr); do
+               time="$(basename "${build}")"
+               [ "${time}" = "latest" ] && continue
+
+               # Never delete the last two builds
+               if [ "${counter}" -lt 2 ]; then
+                       counter=$(( ${counter} + 1 ))
+                       continue
+               fi
+
+               # Determine age of the build
+               change="$(stat --format="%Y" "${build}")"
+               age=$(( ${NOW} - ${change} ))
+
+               # If the build is old enough we will delete it
+               if [[ ${age} -ge ${MAX_AGE} ]]; then
+                       rm -rf "${build}"
+               fi
+       done
 done
 
 exit 0