From e85c43d075f819445489cb517ed8aa3d30ede636 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 22 Feb 2023 18:03:48 +0100 Subject: [PATCH 1/7] Cron: clean nextcloud-aio-domaincheck/tmp volumes Signed-off-by: Zoey --- Containers/mastercontainer/cron.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh index 563b1ef6..82fa4dc7 100644 --- a/Containers/mastercontainer/cron.sh +++ b/Containers/mastercontainer/cron.sh @@ -47,8 +47,14 @@ while true; do # Remove sessions older than 24h find "/mnt/docker-aio-config/session/" -mindepth 1 -mmin +1440 -delete + # Remove nextcloud-aio-domaincheck container + docker container remove nextcloud-aio-domaincheck --force + # Remove dangling images - sudo -u www-data docker image prune -f + sudo -u www-data docker image prune --force + + # Remove dangling volumes + for image in $(docker volume ls --quiet --filter dangling=true | grep -E "^[a-z0-9]{64}$"); do docker volume remove "$image"; done # Wait 60s so that the whole loop will not be executed again sleep 60 From c2444912b847bb8650a71dd0e702178c7f8dabd4 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 22 Feb 2023 18:10:51 +0100 Subject: [PATCH 2/7] the image is a volume... Signed-off-by: Zoey --- Containers/mastercontainer/cron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh index 82fa4dc7..dc9170b1 100644 --- a/Containers/mastercontainer/cron.sh +++ b/Containers/mastercontainer/cron.sh @@ -54,7 +54,7 @@ while true; do sudo -u www-data docker image prune --force # Remove dangling volumes - for image in $(docker volume ls --quiet --filter dangling=true | grep -E "^[a-z0-9]{64}$"); do docker volume remove "$image"; done + for volume in $(docker volume ls --quiet --filter dangling=true | grep -E "^[a-z0-9]{64}$"); do docker volume remove "$volume"; done # Wait 60s so that the whole loop will not be executed again sleep 60 From 9e9e991cb64b98e239686aed5fdc361838263bf9 Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 23 Feb 2023 07:00:05 +0100 Subject: [PATCH 3/7] add sudo Signed-off-by: Zoey --- Containers/mastercontainer/cron.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh index dc9170b1..e8e10be6 100644 --- a/Containers/mastercontainer/cron.sh +++ b/Containers/mastercontainer/cron.sh @@ -48,13 +48,13 @@ while true; do find "/mnt/docker-aio-config/session/" -mindepth 1 -mmin +1440 -delete # Remove nextcloud-aio-domaincheck container - docker container remove nextcloud-aio-domaincheck --force + sudo -u www-data docker container remove nextcloud-aio-domaincheck --force # Remove dangling images sudo -u www-data docker image prune --force # Remove dangling volumes - for volume in $(docker volume ls --quiet --filter dangling=true | grep -E "^[a-z0-9]{64}$"); do docker volume remove "$volume"; done + for volume in $(sudo -u www-data docker volume ls --quiet --filter dangling=true | grep -E "^[a-z0-9]{64}$"); do sudo -u www-data docker volume remove "$volume"; done # Wait 60s so that the whole loop will not be executed again sleep 60 From e2f92a30c6bbbb7903b109fed2c1bffb55933440 Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 23 Feb 2023 18:05:08 +0100 Subject: [PATCH 4/7] remove removing tmp volumes Signed-off-by: Zoey --- Containers/mastercontainer/cron.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh index e8e10be6..f8cedce9 100644 --- a/Containers/mastercontainer/cron.sh +++ b/Containers/mastercontainer/cron.sh @@ -52,9 +52,6 @@ while true; do # Remove dangling images sudo -u www-data docker image prune --force - - # Remove dangling volumes - for volume in $(sudo -u www-data docker volume ls --quiet --filter dangling=true | grep -E "^[a-z0-9]{64}$"); do sudo -u www-data docker volume remove "$volume"; done # Wait 60s so that the whole loop will not be executed again sleep 60 From d7a174615c9954728f555ffa7f40a7088b260773 Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 23 Feb 2023 18:05:34 +0100 Subject: [PATCH 5/7] only remove domaincheck container if it is stopped Signed-off-by: Zoey --- Containers/mastercontainer/cron.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh index f8cedce9..f6250206 100644 --- a/Containers/mastercontainer/cron.sh +++ b/Containers/mastercontainer/cron.sh @@ -48,7 +48,9 @@ while true; do find "/mnt/docker-aio-config/session/" -mindepth 1 -mmin +1440 -delete # Remove nextcloud-aio-domaincheck container - sudo -u www-data docker container remove nextcloud-aio-domaincheck --force + if docker ps --format "{{.Names}}" --filter "status=exited" | grep -qw "^nextcloud-aio-domaincheck$"; then + sudo -u www-data docker container remove nextcloud-aio-domaincheck + fi # Remove dangling images sudo -u www-data docker image prune --force From 73b4c2d3eab4a7ac460e24a1ac1ef23b1423dc0c Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 23 Feb 2023 18:13:22 +0100 Subject: [PATCH 6/7] add missing sudo Signed-off-by: Zoey --- Containers/mastercontainer/cron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh index f6250206..cccda17f 100644 --- a/Containers/mastercontainer/cron.sh +++ b/Containers/mastercontainer/cron.sh @@ -48,7 +48,7 @@ while true; do find "/mnt/docker-aio-config/session/" -mindepth 1 -mmin +1440 -delete # Remove nextcloud-aio-domaincheck container - if docker ps --format "{{.Names}}" --filter "status=exited" | grep -qw "^nextcloud-aio-domaincheck$"; then + if sudo -u www-data docker ps --format "{{.Names}}" --filter "status=exited" | grep -qw "^nextcloud-aio-domaincheck$"; then sudo -u www-data docker container remove nextcloud-aio-domaincheck fi From 3eb3a9ff9fb6c8a28b130f963f58e5e8c78fb7de Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 23 Feb 2023 18:19:51 +0100 Subject: [PATCH 7/7] remove -w from grep Co-authored-by: Simon L. Signed-off-by: Zoey --- Containers/mastercontainer/cron.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Containers/mastercontainer/cron.sh b/Containers/mastercontainer/cron.sh index cccda17f..f5de8a50 100644 --- a/Containers/mastercontainer/cron.sh +++ b/Containers/mastercontainer/cron.sh @@ -48,7 +48,7 @@ while true; do find "/mnt/docker-aio-config/session/" -mindepth 1 -mmin +1440 -delete # Remove nextcloud-aio-domaincheck container - if sudo -u www-data docker ps --format "{{.Names}}" --filter "status=exited" | grep -qw "^nextcloud-aio-domaincheck$"; then + if sudo -u www-data docker ps --format "{{.Names}}" --filter "status=exited" | grep -q "^nextcloud-aio-domaincheck$"; then sudo -u www-data docker container remove nextcloud-aio-domaincheck fi