diff --git a/actions/ejabberd b/actions/ejabberd index aea8b312a..8e7fb4fbe 100755 --- a/actions/ejabberd +++ b/actions/ejabberd @@ -73,10 +73,10 @@ def parse_arguments(): hostname_change.add_argument('--old-hostname', help='Previous hostname') hostname_change.add_argument('--new-hostname', help='New hostname') - # Update ejabberd with new domainname - domainname_change = subparsers.add_parser( - 'change-domainname', help='Update ejabberd with new domainname') - domainname_change.add_argument('--domainname', help='New domainname') + # Add a domain name to ejabberd + add_domain = subparsers.add_parser('add-domain', + help='Add a domain name to ejabberd') + add_domain.add_argument('--domainname', help='New domain name') # Switch/check Message Archive Management (MAM) in ejabberd config help_MAM = 'Switch or check Message Archive Management (MAM).' @@ -219,16 +219,13 @@ def subcommand_change_hostname(arguments): EJABBERD_BACKUP_NEW) -def subcommand_change_domainname(arguments): +def subcommand_add_domain(arguments): """Update ejabberd with new domainname""" if not shutil.which('ejabberdctl'): print('ejabberdctl not found. Is ejabberd installed?') return domainname = arguments.domainname - if not domainname: - # If new domainname is blank, use hostname instead. - domainname = socket.gethostname() # Add updated domainname to ejabberd hosts list. with open(EJABBERD_CONFIG, 'r') as file_handle: diff --git a/plinth/modules/ejabberd/__init__.py b/plinth/modules/ejabberd/__init__.py index 0085a8f10..53718072c 100644 --- a/plinth/modules/ejabberd/__init__.py +++ b/plinth/modules/ejabberd/__init__.py @@ -32,11 +32,11 @@ from plinth.modules import config from plinth.modules.apache.components import Webserver from plinth.modules.firewall.components import Firewall from plinth.modules.letsencrypt.components import LetsEncrypt -from plinth.signals import (domainname_change, post_hostname_change, +from plinth.signals import (domain_added, post_hostname_change, pre_hostname_change) from plinth.utils import format_lazy -from .manifest import backup, clients # noqa, pylint: disable=unused-import +from .manifest import backup, clients # noqa, pylint: disable=unused-import version = 3 @@ -132,7 +132,7 @@ def init(): pre_hostname_change.connect(on_pre_hostname_change) post_hostname_change.connect(on_post_hostname_change) - domainname_change.connect(on_domainname_change) + domain_added.connect(on_domain_added) def setup(helper, old_version=None): @@ -189,14 +189,10 @@ def on_post_hostname_change(sender, old_hostname, new_hostname, **kwargs): ], run_in_background=True) -def on_domainname_change(sender, old_domainname, new_domainname, **kwargs): +def on_domain_added(sender, domain_type, name, description='', services=None, + **kwargs): """Update ejabberd config after domain name change.""" - del sender # Unused - del old_domainname # Unused - del kwargs # Unused - - actions.superuser_run( - 'ejabberd', ['change-domainname', '--domainname', new_domainname]) + actions.superuser_run('ejabberd', ['add-domain', '--domainname', name]) app.get_component('letsencrypt-ejabberd').setup_certificates()