From 49b7130c5a506adaf8cfa9280bce32fd082a4034 Mon Sep 17 00:00:00 2001 From: Salimane Adjao Moustapha Date: Mon, 1 Feb 2016 10:57:38 +0100 Subject: [PATCH] Allow non-looped cleanups, fixes #10 --- Dockerfile | 1 + run.sh | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Dockerfile b/Dockerfile index cea2eca..8e68c39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,5 +10,6 @@ ADD docker-cleanup-volumes.sh /docker-cleanup-volumes.sh ENV CLEAN_PERIOD **None** ENV DELAY_TIME **None** ENV KEEP_IMAGES **None** +ENV LOOP true ENTRYPOINT ["/run.sh"] diff --git a/run.sh b/run.sh index 6a9281a..cea5f86 100755 --- a/run.sh +++ b/run.sh @@ -28,6 +28,10 @@ if [ "${KEEP_IMAGES}" == "**None**" ]; then unset KEEP_IMAGES fi +if [ "${LOOP}" != "false" ]; then + LOOP=true +fi + echo "=> Run the clean script every ${CLEAN_PERIOD} seconds and delay ${DELAY_TIME} seconds to clean." trap '{ echo "User Interupt."; exit 1; }' SIGINT @@ -123,6 +127,10 @@ do fi rm -f ToBeCleanedImageIdList ContainerImageIdList ToBeCleaned ImageIdList KeepImageIdList + + # Run forever or exit after the first run depending on the value of $LOOP + [ "${LOOP}" == "true" ] || break + echo "=> Next clean will be started in ${CLEAN_PERIOD} seconds" sleep ${CLEAN_PERIOD} & wait done