mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
Don't change ejabberd hosts or jwchat sitename when changing hostname.
Update these only when the domain name is changed.
This commit is contained in:
parent
b8a7007552
commit
01bea7808c
75
actions/xmpp
75
actions/xmpp
@ -60,6 +60,12 @@ def parse_arguments():
|
|||||||
hostname_change.add_argument('--new-hostname',
|
hostname_change.add_argument('--new-hostname',
|
||||||
help='New hostname')
|
help='New hostname')
|
||||||
|
|
||||||
|
# Update ejabberd and jwchat with new domainname
|
||||||
|
domainname_change = subparsers.add_parser(
|
||||||
|
'change-domainname',
|
||||||
|
help='Update ejabberd and jwchat with new domainname')
|
||||||
|
domainname_change.add_argument('--domainname', help='New domainname')
|
||||||
|
|
||||||
# Register a new user account
|
# Register a new user account
|
||||||
register = subparsers.add_parser('register',
|
register = subparsers.add_parser('register',
|
||||||
help='Register a new user account')
|
help='Register a new user account')
|
||||||
@ -105,38 +111,6 @@ def subcommand_change_hostname(arguments):
|
|||||||
old_hostname = arguments.old_hostname
|
old_hostname = arguments.old_hostname
|
||||||
new_hostname = arguments.new_hostname
|
new_hostname = arguments.new_hostname
|
||||||
|
|
||||||
# update jwchat's sitename, if it's installed
|
|
||||||
if os.path.exists(JWCHAT_CONFIG):
|
|
||||||
with open(JWCHAT_CONFIG, 'r') as conffile:
|
|
||||||
lines = conffile.readlines()
|
|
||||||
with open(JWCHAT_CONFIG, 'w') as conffile:
|
|
||||||
for line in lines:
|
|
||||||
if re.match(r'\s*var\s+SITENAME', line):
|
|
||||||
conffile.write('var SITENAME = "' + new_hostname + '";\n')
|
|
||||||
else:
|
|
||||||
conffile.write(line)
|
|
||||||
else:
|
|
||||||
print('Skipping configuring jwchat hostname: %s not found'
|
|
||||||
% JWCHAT_CONFIG)
|
|
||||||
|
|
||||||
# update ejabberd hosts
|
|
||||||
with open(EJABBERD_CONFIG, 'r') as conffile:
|
|
||||||
lines = conffile.readlines()
|
|
||||||
with open(EJABBERD_CONFIG, 'w') as conffile:
|
|
||||||
in_hosts_section = False
|
|
||||||
for line in lines:
|
|
||||||
if in_hosts_section:
|
|
||||||
if re.match(r'\s*-\s+"', line):
|
|
||||||
conffile.write(line.replace('"' + old_hostname + '"',
|
|
||||||
'"' + new_hostname + '"'))
|
|
||||||
else:
|
|
||||||
in_hosts_section = False
|
|
||||||
conffile.write(line)
|
|
||||||
else:
|
|
||||||
if re.match(r'\s*hosts:', line):
|
|
||||||
in_hosts_section = True
|
|
||||||
conffile.write(line)
|
|
||||||
|
|
||||||
subprocess.call(['service', 'ejabberd', 'stop'])
|
subprocess.call(['service', 'ejabberd', 'stop'])
|
||||||
subprocess.call(['pkill', '-u', 'ejabberd'])
|
subprocess.call(['pkill', '-u', 'ejabberd'])
|
||||||
|
|
||||||
@ -161,6 +135,43 @@ def subcommand_change_hostname(arguments):
|
|||||||
% EJABBERD_BACKUP_NEW)
|
% EJABBERD_BACKUP_NEW)
|
||||||
|
|
||||||
|
|
||||||
|
def subcommand_change_domainname(arguments):
|
||||||
|
"""Update ejabberd and jwchat with new domainname"""
|
||||||
|
if not get_installed():
|
||||||
|
print('Failed to update XMPP domainname: ejabberd is not installed.')
|
||||||
|
return
|
||||||
|
|
||||||
|
domainname = arguments.domainname
|
||||||
|
|
||||||
|
# update jwchat's sitename, if it's installed
|
||||||
|
if os.path.exists(JWCHAT_CONFIG):
|
||||||
|
with open(JWCHAT_CONFIG, 'r') as conffile:
|
||||||
|
lines = conffile.readlines()
|
||||||
|
with open(JWCHAT_CONFIG, 'w') as conffile:
|
||||||
|
for line in lines:
|
||||||
|
if re.match(r'\s*var\s+SITENAME', line):
|
||||||
|
conffile.write('var SITENAME = "' + domainname + '";\n')
|
||||||
|
else:
|
||||||
|
conffile.write(line)
|
||||||
|
else:
|
||||||
|
print('Skipping configuring jwchat sitename: %s not found',
|
||||||
|
JWCHAT_CONFIG)
|
||||||
|
|
||||||
|
subprocess.call(['service', 'ejabberd', 'stop'])
|
||||||
|
subprocess.call(['pkill', '-u', 'ejabberd'])
|
||||||
|
|
||||||
|
# add new domainname to top of ejabberd hosts list
|
||||||
|
with open(EJABBERD_CONFIG, 'r') as conffile:
|
||||||
|
lines = conffile.readlines()
|
||||||
|
with open(EJABBERD_CONFIG, 'w') as conffile:
|
||||||
|
for line in lines:
|
||||||
|
conffile.write(line)
|
||||||
|
if re.match(r'\s*hosts:', line):
|
||||||
|
conffile.write(' - "' + domainname + '"\n')
|
||||||
|
|
||||||
|
subprocess.call(['service', 'ejabberd', 'start'])
|
||||||
|
|
||||||
|
|
||||||
def subcommand_register(arguments):
|
def subcommand_register(arguments):
|
||||||
"""Register a new user account"""
|
"""Register a new user account"""
|
||||||
if not get_installed():
|
if not get_installed():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user