mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
Remove deprecated settings from already existing config files
Signed-off-by: Hemanth Kumar Veeranki <hems.india1997@gmail.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
6ce6996793
commit
fafd28e90a
@ -28,6 +28,7 @@ import stat
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import ruamel.yaml
|
import ruamel.yaml
|
||||||
|
from distutils.version import LooseVersion as LV
|
||||||
|
|
||||||
from plinth import action_utils
|
from plinth import action_utils
|
||||||
from plinth.modules import config
|
from plinth.modules import config
|
||||||
@ -38,6 +39,8 @@ EJABBERD_CONFIG = '/etc/ejabberd/ejabberd.yml'
|
|||||||
EJABBERD_BACKUP = '/var/log/ejabberd/ejabberd.dump'
|
EJABBERD_BACKUP = '/var/log/ejabberd/ejabberd.dump'
|
||||||
EJABBERD_BACKUP_NEW = '/var/log/ejabberd/ejabberd_new.dump'
|
EJABBERD_BACKUP_NEW = '/var/log/ejabberd/ejabberd_new.dump'
|
||||||
EJABBERD_ORIG_CERT = '/etc/ejabberd/ejabberd.pem'
|
EJABBERD_ORIG_CERT = '/etc/ejabberd/ejabberd.pem'
|
||||||
|
IQDISC_DEPRECATED_VERSION = LV('18.03')
|
||||||
|
MOD_IRC_DEPRECATED_VERSION = LV('18.06')
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
@ -94,6 +97,8 @@ def parse_arguments():
|
|||||||
letsencrypt.add_argument('command', choices=('add', 'drop'), help=help_LE)
|
letsencrypt.add_argument('command', choices=('add', 'drop'), help=help_LE)
|
||||||
letsencrypt.add_argument('--domain', help='Domain name to drop.')
|
letsencrypt.add_argument('--domain', help='Domain name to drop.')
|
||||||
|
|
||||||
|
subparsers.add_parser('fix-config', help='Fix the deprecated config files')
|
||||||
|
|
||||||
subparsers.required = True
|
subparsers.required = True
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
@ -355,6 +360,39 @@ def subcommand_letsencrypt(arguments):
|
|||||||
action_utils.service_restart('ejabberd')
|
action_utils.service_restart('ejabberd')
|
||||||
|
|
||||||
|
|
||||||
|
def subcommand_fix_config(_):
|
||||||
|
""" Fix the config file by removing deprecated settings"""
|
||||||
|
current_version = _get_version()
|
||||||
|
if not current_version:
|
||||||
|
print('Unable to get the version. Check if ejabberd is installed')
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(EJABBERD_CONFIG, 'r') as file_handle:
|
||||||
|
conf = ruamel.yaml.round_trip_load(file_handle, preserve_quotes=True)
|
||||||
|
|
||||||
|
# Check if `iqdisc` is present and remove it
|
||||||
|
if 'mod_mam' in conf['modules'] and current_version > IQDISC_DEPRECATED_VERSION:
|
||||||
|
conf['modules']['mod_mam'].pop('iqdisc', None)
|
||||||
|
|
||||||
|
# check if mod_irc is present in modules and remove it
|
||||||
|
if 'mod_irc' in conf['modules'] and current_version > MOD_IRC_DEPRECATED_VERSION:
|
||||||
|
conf['modules'].pop('mod_irc')
|
||||||
|
|
||||||
|
# Write changes back to the file
|
||||||
|
with open(EJABBERD_CONFIG, 'w') as file_handle:
|
||||||
|
ruamel.yaml.round_trip_dump(conf, file_handle)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_version():
|
||||||
|
""" Get the current ejabberd version """
|
||||||
|
output = subprocess.check_output(['ejabberdctl', 'status']).decode('utf-8')
|
||||||
|
version_info = output.strip().split('\n')[-1].split()
|
||||||
|
if version_info:
|
||||||
|
version = str(version_info[1])
|
||||||
|
return LV(version)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Parse arguments and perform all duties"""
|
"""Parse arguments and perform all duties"""
|
||||||
arguments = parse_arguments()
|
arguments = parse_arguments()
|
||||||
|
|||||||
@ -33,7 +33,7 @@ from plinth.utils import format_lazy
|
|||||||
|
|
||||||
from .manifest import backup, clients
|
from .manifest import backup, clients
|
||||||
|
|
||||||
version = 1
|
version = 2
|
||||||
|
|
||||||
managed_services = ['ejabberd']
|
managed_services = ['ejabberd']
|
||||||
|
|
||||||
@ -97,6 +97,7 @@ def setup(helper, old_version=None):
|
|||||||
['pre-install', '--domainname', domainname])
|
['pre-install', '--domainname', domainname])
|
||||||
helper.install(managed_packages)
|
helper.install(managed_packages)
|
||||||
helper.call('post', actions.superuser_run, 'ejabberd', ['setup'])
|
helper.call('post', actions.superuser_run, 'ejabberd', ['setup'])
|
||||||
|
actions.superuser_run('ejabberd', ['fix-config'])
|
||||||
global service
|
global service
|
||||||
if service is None:
|
if service is None:
|
||||||
service = service_module.Service(
|
service = service_module.Service(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user