Refactored due to the reason that it was planed to also include akaunting update procedures. But this is skipped for now

This commit is contained in:
Kevin Veen-Birkenbach 2023-11-30 17:55:23 +01:00
parent 12d88df11f
commit 0187f2797e

View File

@ -90,12 +90,16 @@ def update_docker(directory):
else: else:
print("Docker images are up to date. No rebuild necessary.") print("Docker images are up to date. No rebuild necessary.")
def update_nextcloud(directory): def update_nextcloud():
print("Updating Nextcloud apps.") 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 max_attempts = 3
for attempt in range(max_attempts): for attempt in range(max_attempts):
try: 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 break # If the command succeeds, exit the loop
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
if attempt < max_attempts - 1: # Check if it's not the last attempt if attempt < max_attempts - 1: # Check if it's not the last attempt
@ -130,4 +134,4 @@ if __name__ == "__main__":
update_docker(dir_path) update_docker(dir_path)
if os.path.basename(dir_path) == "nextcloud": if os.path.basename(dir_path) == "nextcloud":
update_nextcloud(dir_path) update_nextcloud()