mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
Signal xmpp module before and after hostname is changed.
This commit is contained in:
parent
10b234921b
commit
298938de73
@ -31,6 +31,7 @@ import socket
|
|||||||
|
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
|
from plinth.signals import pre_hostname_change, post_hostname_change
|
||||||
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
@ -160,9 +161,13 @@ def set_hostname(hostname):
|
|||||||
# valid_hostname check, convert to ASCII.
|
# valid_hostname check, convert to ASCII.
|
||||||
hostname = str(hostname)
|
hostname = str(hostname)
|
||||||
|
|
||||||
|
pre_hostname_change.send_robust(sender='config',
|
||||||
|
old_hostname=old_hostname,
|
||||||
|
new_hostname=hostname)
|
||||||
|
|
||||||
LOGGER.info('Changing hostname to - %s', hostname)
|
LOGGER.info('Changing hostname to - %s', hostname)
|
||||||
actions.superuser_run('xmpp-pre-hostname-change')
|
|
||||||
actions.superuser_run('hostname-change', hostname)
|
actions.superuser_run('hostname-change', hostname)
|
||||||
actions.superuser_run('xmpp', 'change-hostname',
|
|
||||||
'--old-hostname', old_hostname,
|
post_hostname_change.send_robust(sender='config',
|
||||||
'--new-hostname', hostname, async=True)
|
old_hostname=old_hostname,
|
||||||
|
new_hostname=hostname)
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import logging
|
|||||||
from plinth import actions
|
from plinth import actions
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
from plinth import service
|
from plinth import service
|
||||||
|
from plinth.signals import pre_hostname_change, post_hostname_change
|
||||||
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
@ -53,6 +54,9 @@ def init():
|
|||||||
'xmpp-bosh', _('Chat Server - web interface'), is_external=True,
|
'xmpp-bosh', _('Chat Server - web interface'), is_external=True,
|
||||||
enabled=True)
|
enabled=True)
|
||||||
|
|
||||||
|
pre_hostname_change.connect(on_pre_hostname_change)
|
||||||
|
post_hostname_change.connect(on_post_hostname_change)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index(request):
|
def index(request):
|
||||||
@ -178,3 +182,27 @@ def _register_user(request, data):
|
|||||||
messages.error(request,
|
messages.error(request,
|
||||||
_('Failed to register account for %s: %s') %
|
_('Failed to register account for %s: %s') %
|
||||||
(data['username'], output))
|
(data['username'], output))
|
||||||
|
|
||||||
|
|
||||||
|
def on_pre_hostname_change(sender, old_hostname, new_hostname, **kwargs):
|
||||||
|
"""
|
||||||
|
Backup ejabberd database before hostname is changed.
|
||||||
|
"""
|
||||||
|
del sender # Unused
|
||||||
|
del old_hostname # Unused
|
||||||
|
del new_hostname # Unused
|
||||||
|
del kwargs # Unused
|
||||||
|
|
||||||
|
actions.superuser_run('xmpp-pre-hostname-change')
|
||||||
|
|
||||||
|
|
||||||
|
def on_post_hostname_change(sender, old_hostname, new_hostname, **kwargs):
|
||||||
|
"""
|
||||||
|
Update ejabberd and jwchat config after hostname is changed.
|
||||||
|
"""
|
||||||
|
del sender # Unused
|
||||||
|
del kwargs # Unused
|
||||||
|
|
||||||
|
actions.superuser_run('xmpp', 'change-hostname',
|
||||||
|
'--old-hostname', old_hostname,
|
||||||
|
'--new-hostname', hostname, async=True)
|
||||||
|
|||||||
@ -25,3 +25,5 @@ from django.dispatch import Signal
|
|||||||
service_enabled = Signal(providing_args=['service_id', 'enabled'])
|
service_enabled = Signal(providing_args=['service_id', 'enabled'])
|
||||||
pre_module_loading = Signal()
|
pre_module_loading = Signal()
|
||||||
post_module_loading = Signal()
|
post_module_loading = Signal()
|
||||||
|
pre_hostname_change = Signal(providing_args=['old_hostname', 'new_hostname'])
|
||||||
|
post_hostname_change = Signal(providing_args=['old_hostname', 'new_hostname'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user