mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
ejabberd: Use domain added signal for listening to domain changes
In the action, the new domain is always extended to the list of domain names accepted by ejabberd. To simplify domain handling simply use the domain_added signal. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
0d0ee32a87
commit
0dba497383
@ -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:
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user