nextcloud: Allow re-running setup when app is disabled

- Enable the redis drop-in configurations before redis-server is started so that
the configuration is effective.

- When app is disabled and re-running setup, disable it after running setup
because setup() enables it.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-04-17 19:09:40 -07:00 committed by James Valleroy
parent 685e636a93
commit 1272be0ad6
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -119,17 +119,24 @@ class NextcloudApp(app_module.App):
def setup(self, old_version):
"""Install and configure the app."""
super().setup(old_version)
with self.get_component(
'shared-daemon-nextcloud-redis').ensure_running():
with self.get_component(
'shared-daemon-nextcloud-mysql').ensure_running():
# Drop-in configs need to be enabled for setup to succeed
self.get_component('dropin-configs-nextcloud').enable()
redis = self.get_component('shared-daemon-nextcloud-redis')
mysql = self.get_component('shared-daemon-nextcloud-mysql')
nextcloud = self.get_component('daemon-nextcloud')
# Determine whether app should be disabled after setup
should_disable = old_version and not nextcloud.is_enabled()
with redis.ensure_running():
with mysql.ensure_running():
# Database needs to be running for successful initialization or
# upgrade of Nextcloud database.
# Drop-in configs need to be enabled for setup to succeed
self.get_component('dropin-configs-nextcloud').enable()
privileged.setup()
if should_disable:
self.disable()
if not old_version:
self.enable()