diff --git a/actions/users b/actions/users index f7feddf35..d1c9532cc 100755 --- a/actions/users +++ b/actions/users @@ -39,6 +39,7 @@ def parse_arguments(): parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') + subparsers.add_parser('first-setup', help='Perform initial setup of LDAP') subparsers.add_parser('setup', help='Setup LDAP') subparser = subparsers.add_parser('create-user', @@ -90,6 +91,13 @@ def parse_arguments(): return parser.parse_args() +def subcommand_first_setup(_): + """Perform initial setup of LDAP.""" + # Avoid reconfiguration of slapd during module upgrades, because + # this will move the existing database. + action_utils.dpkg_reconfigure('slapd', {'domain': 'thisbox'}) + + def subcommand_setup(_): """Setup LDAP.""" # Update pam configs for access and mkhomedir. @@ -97,14 +105,13 @@ def subcommand_setup(_): configure_ldapscripts() - configure_slapd() + configure_ldap_authentication() configure_ldap_structure() -def configure_slapd(): +def configure_ldap_authentication(): """Configure LDAP authentication.""" - action_utils.dpkg_reconfigure('slapd', {'domain': 'thisbox'}) action_utils.dpkg_reconfigure('nslcd', { 'ldap-uris': 'ldapi:///', 'ldap-base': 'dc=thisbox', diff --git a/plinth/modules/users/__init__.py b/plinth/modules/users/__init__.py index 3db4d1210..3a001d020 100644 --- a/plinth/modules/users/__init__.py +++ b/plinth/modules/users/__init__.py @@ -25,7 +25,7 @@ from django.utils.translation import ugettext_lazy as _ from plinth import action_utils, actions from plinth.menu import main_menu -version = 1 +version = 2 is_essential = True @@ -57,6 +57,8 @@ def init(): def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) + if old_version is None: + helper.call('post', actions.superuser_run, 'users', ['first-setup']) helper.call('post', actions.superuser_run, 'users', ['setup'])