mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
Convert xmpp-pre-hostname-change to python, merge into xmpp action file.
This commit is contained in:
parent
219b7ff862
commit
90c9e3b9a8
27
actions/xmpp
27
actions/xmpp
@ -41,6 +41,15 @@ def parse_arguments():
|
|||||||
subparsers.add_parser('get-installed',
|
subparsers.add_parser('get-installed',
|
||||||
help='Get whether ejabberd is installed')
|
help='Get whether ejabberd is installed')
|
||||||
|
|
||||||
|
# Prepare ejabberd for hostname change
|
||||||
|
pre_hostname_change = subparsers.add_parser(
|
||||||
|
'pre-change-hostname',
|
||||||
|
help='Prepare ejabberd for hostname change')
|
||||||
|
pre_hostname_change.add_argument('--old-hostname',
|
||||||
|
help='Previous hostname')
|
||||||
|
pre_hostname_change.add_argument('--new-hostname',
|
||||||
|
help='New hostname')
|
||||||
|
|
||||||
# Update ejabberd and jwchat with new hostname
|
# Update ejabberd and jwchat with new hostname
|
||||||
hostname_change = subparsers.add_parser(
|
hostname_change = subparsers.add_parser(
|
||||||
'change-hostname',
|
'change-hostname',
|
||||||
@ -66,6 +75,24 @@ def subcommand_get_installed(_):
|
|||||||
print('installed' if get_installed() else 'not installed')
|
print('installed' if get_installed() else 'not installed')
|
||||||
|
|
||||||
|
|
||||||
|
def subcommand_pre_change_hostname(arguments):
|
||||||
|
"""Prepare ejabberd for hostname change"""
|
||||||
|
if not get_installed():
|
||||||
|
print('Failed to update XMPP hostname: ejabberd is not installed.')
|
||||||
|
return
|
||||||
|
|
||||||
|
old_hostname = arguments.old_hostname
|
||||||
|
new_hostname = arguments.new_hostname
|
||||||
|
|
||||||
|
subprocess.call(['ejabberdctl', 'dump', EJABBERD_BACKUP])
|
||||||
|
subprocess.call(['ejabberdctl', 'stop'])
|
||||||
|
|
||||||
|
# Make sure there aren't files in the Mnesia spool dir
|
||||||
|
os.makedirs('/var/lib/ejabberd/oldfiles', exist_ok=True)
|
||||||
|
subprocess.call('mv /var/lib/ejabberd/*.* /var/lib/ejabberd/oldfiles/',
|
||||||
|
shell=True)
|
||||||
|
|
||||||
|
|
||||||
def subcommand_change_hostname(arguments):
|
def subcommand_change_hostname(arguments):
|
||||||
"""Update ejabberd and jwchat with new hostname"""
|
"""Update ejabberd and jwchat with new hostname"""
|
||||||
if not get_installed():
|
if not get_installed():
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# This file is part of Plinth.
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Action to backup ejabberd database before changing hostname.
|
|
||||||
|
|
||||||
BACKUP=/var/log/ejabberd/ejabberd.dump
|
|
||||||
ejabberdctl dump $BACKUP
|
|
||||||
ejabberdctl stop
|
|
||||||
|
|
||||||
# Make sure there aren't files in the Mnesia spool dir
|
|
||||||
mkdir -p /var/lib/ejabberd/oldfiles
|
|
||||||
mv /var/lib/ejabberd/*.* /var/lib/ejabberd/oldfiles/
|
|
||||||
@ -189,11 +189,12 @@ def on_pre_hostname_change(sender, old_hostname, new_hostname, **kwargs):
|
|||||||
Backup ejabberd database before hostname is changed.
|
Backup ejabberd database before hostname is changed.
|
||||||
"""
|
"""
|
||||||
del sender # Unused
|
del sender # Unused
|
||||||
del old_hostname # Unused
|
|
||||||
del new_hostname # Unused
|
|
||||||
del kwargs # Unused
|
del kwargs # Unused
|
||||||
|
|
||||||
actions.superuser_run('xmpp-pre-hostname-change')
|
actions.superuser_run('xmpp',
|
||||||
|
['pre-change-hostname',
|
||||||
|
'--old-hostname', old_hostname,
|
||||||
|
'--new-hostname', new_hostname])
|
||||||
|
|
||||||
|
|
||||||
def on_post_hostname_change(sender, old_hostname, new_hostname, **kwargs):
|
def on_post_hostname_change(sender, old_hostname, new_hostname, **kwargs):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user