From 614bea45113ace35948f95eb9c9ea46f9cbebda6 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 15 Apr 2024 10:50:46 -0700 Subject: [PATCH] nextcloud: Restart container when dependent services are restarted This is required because when services are restarted, their Unix domain sockets are removed and new ones are created. The container will still be using the old sockets and will fail to connect to the service. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/action_utils.py | 6 +++++- plinth/modules/nextcloud/privileged.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plinth/action_utils.py b/plinth/action_utils.py index c4b338e56..881a7f5b4 100644 --- a/plinth/action_utils.py +++ b/plinth/action_utils.py @@ -491,7 +491,8 @@ def is_package_manager_busy(): def podman_create(container_name: str, image_name: str, volume_name: str, volume_path: str, volumes: dict[str, str] | None = None, - env: dict[str, str] | None = None): + env: dict[str, str] | None = None, + binds_to: list[str] | None = None): """Remove and recreate a podman container.""" service_stop(f'{volume_name}-volume.service') service_stop(container_name) @@ -526,9 +527,12 @@ Options=bind ]) env_lines = '\n'.join( [f'Environment={key}={value}' for key, value in (env or {}).items()]) + bind_lines = '\n'.join(f'BindsTo={service}\nAfter={service}' + for service in (binds_to or [])) contents = f'''[Unit] Requires=nextcloud-freedombox-volume.service After=nextcloud-freedombox-volume.service +{bind_lines} [Container] AutoUpdate=registry diff --git a/plinth/modules/nextcloud/privileged.py b/plinth/modules/nextcloud/privileged.py index 74efb2e56..6b080ddf6 100644 --- a/plinth/modules/nextcloud/privileged.py +++ b/plinth/modules/nextcloud/privileged.py @@ -52,10 +52,11 @@ def setup(): VOLUME_NAME: '/var/www/html' } env = {'OVERWRITEWEBROOT': '/nextcloud'} + binds_to = ['mariadb.service', 'redis-server.service', 'slapd.service'] action_utils.podman_create(container_name=CONTAINER_NAME, image_name=IMAGE_NAME, volume_name=VOLUME_NAME, volume_path=str(_data_path), volumes=volumes, - env=env) + env=env, binds_to=binds_to) action_utils.service_start(CONTAINER_NAME) _nextcloud_wait_until_ready()