mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
ejabberd: Prevent restart on freedombox startup
Closes: #1641 Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
b87930406e
commit
29ae2edcd1
@ -20,6 +20,7 @@ Configuration helper for the ejabberd service
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
@ -46,6 +47,10 @@ def parse_arguments():
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||
|
||||
# Get configuration
|
||||
subparsers.add_parser('get-configuration',
|
||||
help='Return the current configuration')
|
||||
|
||||
# Preseed debconf values before packages are installed.
|
||||
pre_install = subparsers.add_parser(
|
||||
'pre-install',
|
||||
@ -93,6 +98,14 @@ def parse_arguments():
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def subcommand_get_configuration(_):
|
||||
"""Return the current configuration, specifically domains configured."""
|
||||
with open(EJABBERD_CONFIG, 'r') as file_handle:
|
||||
conf = ruamel.yaml.round_trip_load(file_handle, preserve_quotes=True)
|
||||
|
||||
print(json.dumps({'domains': conf['hosts']}))
|
||||
|
||||
|
||||
def subcommand_pre_install(arguments):
|
||||
"""Preseed debconf values before packages are installed."""
|
||||
domainname = arguments.domainname
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
FreedomBox app to configure ejabberd server.
|
||||
"""
|
||||
|
||||
import json
|
||||
import logging
|
||||
import pathlib
|
||||
|
||||
@ -196,8 +197,11 @@ def on_post_hostname_change(sender, old_hostname, new_hostname, **kwargs):
|
||||
def on_domain_added(sender, domain_type, name, description='', services=None,
|
||||
**kwargs):
|
||||
"""Update ejabberd config after domain name change."""
|
||||
actions.superuser_run('ejabberd', ['add-domain', '--domainname', name])
|
||||
app.get_component('letsencrypt-ejabberd').setup_certificates()
|
||||
conf = actions.superuser_run('ejabberd', ['get-configuration'])
|
||||
conf = json.loads(conf)
|
||||
if name not in conf['domains']:
|
||||
actions.superuser_run('ejabberd', ['add-domain', '--domainname', name])
|
||||
app.get_component('letsencrypt-ejabberd').setup_certificates()
|
||||
|
||||
|
||||
def diagnose():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user