mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +00:00
xmpp: Replace host list instead of adding during domainname change (Closes #167).
This commit is contained in:
parent
6ecd184d37
commit
162b28aafe
14
actions/xmpp
14
actions/xmpp
@ -27,7 +27,6 @@ import shutil
|
|||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
import yaml
|
|
||||||
|
|
||||||
from plinth import action_utils
|
from plinth import action_utils
|
||||||
|
|
||||||
@ -214,12 +213,6 @@ def subcommand_change_domainname(arguments):
|
|||||||
print('Skipping configuring jwchat sitename: %s not found',
|
print('Skipping configuring jwchat sitename: %s not found',
|
||||||
JWCHAT_CONFIG)
|
JWCHAT_CONFIG)
|
||||||
|
|
||||||
# Check if new domainname is already in ejabberd hosts list.
|
|
||||||
conffile = open(EJABBERD_CONFIG, 'r')
|
|
||||||
conf = yaml.safe_load(conffile)
|
|
||||||
if domainname in conf['hosts']:
|
|
||||||
return
|
|
||||||
|
|
||||||
action_utils.service_stop('ejabberd')
|
action_utils.service_stop('ejabberd')
|
||||||
subprocess.call(['pkill', '-u', 'ejabberd'])
|
subprocess.call(['pkill', '-u', 'ejabberd'])
|
||||||
|
|
||||||
@ -227,9 +220,16 @@ def subcommand_change_domainname(arguments):
|
|||||||
with open(EJABBERD_CONFIG, 'r') as conffile:
|
with open(EJABBERD_CONFIG, 'r') as conffile:
|
||||||
lines = conffile.readlines()
|
lines = conffile.readlines()
|
||||||
with open(EJABBERD_CONFIG, 'w') as conffile:
|
with open(EJABBERD_CONFIG, 'w') as conffile:
|
||||||
|
in_hosts = False
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
if in_hosts:
|
||||||
|
if re.match(r'\s*-\s*', line):
|
||||||
|
continue
|
||||||
|
in_hosts = False
|
||||||
|
|
||||||
conffile.write(line)
|
conffile.write(line)
|
||||||
if re.match(r'\s*hosts:', line):
|
if re.match(r'\s*hosts:', line):
|
||||||
|
in_hosts = True
|
||||||
conffile.write(' - "' + domainname + '"\n')
|
conffile.write(' - "' + domainname + '"\n')
|
||||||
|
|
||||||
action_utils.service_start('ejabberd')
|
action_utils.service_start('ejabberd')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user