From af10f1f0d82ed66c76b6451606e8ce20058343a4 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 30 Nov 2023 17:55:23 +0100 Subject: [PATCH] Refactored due to the reason that it was planed to also include akaunting update procedures. But this is skipped for now --- roles/update-docker/files/update-docker.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/roles/update-docker/files/update-docker.py b/roles/update-docker/files/update-docker.py index 28290b45..eb19bb95 100644 --- a/roles/update-docker/files/update-docker.py +++ b/roles/update-docker/files/update-docker.py @@ -90,12 +90,16 @@ def update_docker(directory): else: print("Docker images are up to date. No rebuild necessary.") -def update_nextcloud(directory): - print("Updating Nextcloud apps.") +def update_nextcloud(): + print("Start Nextcloud update procedure.") + update_procedure("docker-compose exec -T -u www-data application /var/www/html/occ app:update --all") + +# This procedure waits until the container is up +def update_procedure(command): max_attempts = 3 for attempt in range(max_attempts): try: - run_command("docker-compose exec -T -u www-data application /var/www/html/occ app:update --all") + run_command(command) break # If the command succeeds, exit the loop except subprocess.CalledProcessError as e: if attempt < max_attempts - 1: # Check if it's not the last attempt @@ -130,4 +134,4 @@ if __name__ == "__main__": update_docker(dir_path) if os.path.basename(dir_path) == "nextcloud": - update_nextcloud(dir_path) + update_nextcloud()