mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
Change hostname for some more fields that may appear in ejabberd backup database.
This commit is contained in:
parent
588eb7250e
commit
c12fbec30f
54
actions/xmpp
54
actions/xmpp
@ -23,7 +23,6 @@ Configuration helper for the ejabberd service
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -81,9 +80,9 @@ def subcommand_change_hostname(arguments):
|
|||||||
lines = conffile.readlines()
|
lines = conffile.readlines()
|
||||||
with open(JWCHAT_CONFIG, 'w') as conffile:
|
with open(JWCHAT_CONFIG, 'w') as conffile:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
conffile.write(re.sub('var SITENAME = "' + old_hostname + '";',
|
conffile.write(line.replace(
|
||||||
'var SITENAME = "' + new_hostname + '";',
|
'var SITENAME = "' + old_hostname + '";',
|
||||||
line))
|
'var SITENAME = "' + new_hostname + '";'))
|
||||||
else:
|
else:
|
||||||
print('Skipping configuring jwchat hostname: %s not found'
|
print('Skipping configuring jwchat hostname: %s not found'
|
||||||
% JWCHAT_CONFIG)
|
% JWCHAT_CONFIG)
|
||||||
@ -110,33 +109,54 @@ def subcommand_change_hostname(arguments):
|
|||||||
with open(EJABBERD_BACKUP, 'r') as dumpfile:
|
with open(EJABBERD_BACKUP, 'r') as dumpfile:
|
||||||
lines = dumpfile.readlines()
|
lines = dumpfile.readlines()
|
||||||
with open(EJABBERD_BACKUP, 'w') as dumpfile:
|
with open(EJABBERD_BACKUP, 'w') as dumpfile:
|
||||||
|
in_roster = False
|
||||||
in_pubsub_node = False
|
in_pubsub_node = False
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
if in_roster:
|
||||||
|
if line.startswith(' '):
|
||||||
|
dumpfile.write(line.replace(
|
||||||
|
'>>,<<"' + old_hostname + '">>',
|
||||||
|
'>>,<<"' + new_hostname + '">>'))
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
in_roster = False # check other cases below
|
||||||
|
|
||||||
if in_pubsub_node:
|
if in_pubsub_node:
|
||||||
if line.startswith(' '):
|
if line.startswith(' '):
|
||||||
dumpfile.write(re.sub(
|
dumpfile.write(line.replace(
|
||||||
'>>,<<pubsub.' + old_hostname + '">>,',
|
'>>,<<"pubsub.' + old_hostname + '">>,<<',
|
||||||
'>>,<<pubsub.' + new_hostname + '">>,',
|
'>>,<<"pubsub.' + new_hostname + '">>,<<'))
|
||||||
line))
|
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
in_pubsub_node = False # check other cases below
|
in_pubsub_node = False # check other cases below
|
||||||
|
|
||||||
if line.startswith('{passwd,'):
|
if line.startswith('{passwd,'):
|
||||||
dumpfile.write(re.sub(
|
dumpfile.write(line.replace(
|
||||||
'">>,<<"' + old_hostname + '">>},<<"',
|
'">>,<<"' + old_hostname + '">>},<<"',
|
||||||
'">>,<<"' + new_hostname + '">>},<<"',
|
'">>,<<"' + new_hostname + '">>},<<"'))
|
||||||
line))
|
elif line.startswith('{private_storage,'):
|
||||||
|
dumpfile.write(line.replace(
|
||||||
|
'>>,<<"' + old_hostname + '">>,<<',
|
||||||
|
'>>,<<"' + new_hostname + '">>,<<'))
|
||||||
|
elif line.startswith('{last_activity,'):
|
||||||
|
dumpfile.write(line.replace(
|
||||||
|
'>>,<<"' + old_hostname + '">>},',
|
||||||
|
'>>,<<"' + new_hostname + '">>},'))
|
||||||
|
elif line.startswith('{roster,'):
|
||||||
|
dumpfile.write(line.replace(
|
||||||
|
'>>,<<"' + old_hostname + '">>,',
|
||||||
|
'>>,<<"' + new_hostname + '">>,'))
|
||||||
|
in_roster = True
|
||||||
elif line.startswith('{pubsub_state,'):
|
elif line.startswith('{pubsub_state,'):
|
||||||
dumpfile.write(re.sub(
|
dumpfile.write(line.replace(
|
||||||
'>>,<<"pubsub.' + old_hostname + '">>,<<',
|
'>>,<<"pubsub.' + old_hostname + '">>,<<',
|
||||||
'>>,<<"pubsub.' + new_hostname + '">>,<<',
|
'>>,<<"pubsub.' + new_hostname + '">>,<<'))
|
||||||
line))
|
|
||||||
elif line.startswith('{pubsub_node,'):
|
elif line.startswith('{pubsub_node,'):
|
||||||
dumpfile.write(re.sub(
|
dumpfile.write(line.replace(
|
||||||
',{<<"pubsub.' + old_hostname + '">>,<<',
|
',{<<"pubsub.' + old_hostname + '">>,<<',
|
||||||
',{<<"pubsub.' + new_hostname + '">>,<<',
|
',{<<"pubsub.' + new_hostname + '">>,<<').replace(
|
||||||
line))
|
'>>,<<"/home/' + old_hostname + '">>},',
|
||||||
|
'>>,<<"/home/' + new_hostname + '"..},'))
|
||||||
in_pubsub_node = True
|
in_pubsub_node = True
|
||||||
else:
|
else:
|
||||||
dumpfile.write(line)
|
dumpfile.write(line)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user