From 52c4783c4a4351c804550e29d4e51850fb9b2de2 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 1 Apr 2024 15:21:39 -0700 Subject: [PATCH] nextcloud: Improve setting up LDAP configuration Running ldap:test-config before enabling the 'user_ldap' app lead to bad output. 'app:enable' and 'ldap:set-config' are idempotent. So, re-run them in setup. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/nextcloud/privileged.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/plinth/modules/nextcloud/privileged.py b/plinth/modules/nextcloud/privileged.py index c5769ad4e..6560ae710 100644 --- a/plinth/modules/nextcloud/privileged.py +++ b/plinth/modules/nextcloud/privileged.py @@ -74,14 +74,8 @@ def setup(): _set_redis_password(_generate_secret_key(16)) action_utils.service_restart('redis-server') _create_redis_config(_get_redis_password()) - # Check if LDAP has already been configured. This is necessary because - # if the setup proccess is rerun when updating the FredomBox app another - # redundant LDAP config would be created. - is_ldap_configured = _run_occ('ldap:test-config', 's01', - capture_output=True) - if is_ldap_configured != ('The configuration is valid and the connection ' - 'could be established!'): - _configure_ldap() + + _configure_ldap() _configure_systemd() @@ -210,7 +204,14 @@ def _nextcloud_setup_wizard(db_password, admin_password): def _configure_ldap(): _run_occ('app:enable', 'user_ldap') - _run_occ('ldap:create-empty-config') + + # Check if LDAP has already been configured. This is necessary because + # if the setup proccess is rerun when updating the FredomBox app another + # redundant LDAP config would be created. + output = _run_occ('ldap:test-config', 's01', capture_output=True, + check=False) + if 'Invalid configID' in output.stdout.decode(): + _run_occ('ldap:create-empty-config') ldap_settings = { 'ldapBase': 'dc=thisbox',