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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2024-04-01 15:21:39 -07:00 committed by James Valleroy
parent d9132661c5
commit 52c4783c4a
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -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',