users: Handle upgrade for ldapscripts config

Increment users module version so existing users will get FreedomBox
copy of ldapscripts config file.

Avoid reconfiguration of slapd during module upgrade, because this
will move the existing database.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2017-10-23 19:53:53 -04:00 committed by Sunil Mohan Adapa
parent 4cbb60ccfe
commit 87eecb7c62
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 13 additions and 4 deletions

View File

@ -39,6 +39,7 @@ def parse_arguments():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command') 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') subparsers.add_parser('setup', help='Setup LDAP')
subparser = subparsers.add_parser('create-user', subparser = subparsers.add_parser('create-user',
@ -90,6 +91,13 @@ def parse_arguments():
return parser.parse_args() 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(_): def subcommand_setup(_):
"""Setup LDAP.""" """Setup LDAP."""
# Update pam configs for access and mkhomedir. # Update pam configs for access and mkhomedir.
@ -97,14 +105,13 @@ def subcommand_setup(_):
configure_ldapscripts() configure_ldapscripts()
configure_slapd() configure_ldap_authentication()
configure_ldap_structure() configure_ldap_structure()
def configure_slapd(): def configure_ldap_authentication():
"""Configure LDAP authentication.""" """Configure LDAP authentication."""
action_utils.dpkg_reconfigure('slapd', {'domain': 'thisbox'})
action_utils.dpkg_reconfigure('nslcd', { action_utils.dpkg_reconfigure('nslcd', {
'ldap-uris': 'ldapi:///', 'ldap-uris': 'ldapi:///',
'ldap-base': 'dc=thisbox', 'ldap-base': 'dc=thisbox',

View File

@ -25,7 +25,7 @@ from django.utils.translation import ugettext_lazy as _
from plinth import action_utils, actions from plinth import action_utils, actions
from plinth.menu import main_menu from plinth.menu import main_menu
version = 1 version = 2
is_essential = True is_essential = True
@ -57,6 +57,8 @@ def init():
def setup(helper, old_version=None): def setup(helper, old_version=None):
"""Install and configure the module.""" """Install and configure the module."""
helper.install(managed_packages) 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']) helper.call('post', actions.superuser_run, 'users', ['setup'])