Convert xmpp-pre-hostname-change to python, merge into xmpp action file.

This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2015-01-03 14:43:50 +05:30
1 parent 219b7ff862
commit 90c9e3b9a8
3 files changed
+31 -30

No files matched your search

+27
View File
@@ -41,6 +41,15 @@ def parse_arguments():
subparsers.add_parser('get-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
hostname_change = subparsers.add_parser(
'change-hostname',
@@ -66,6 +75,24 @@ def subcommand_get_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):
"""Update ejabberd and jwchat with new hostname"""
if not get_installed():
-27
View File
@@ -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/