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()