radicale: Don't modify default file for radicale >= 2.1.10

/etc/default/radicale is not used in radicale 2.1.10-1 and later.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
James Valleroy 2018-12-27 13:30:47 -05:00
parent 6adec225d3
commit 1b4d42cd53
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -22,11 +22,14 @@ Configuration helper for Radicale.
import argparse
import augeas
import subprocess
from distutils.version import LooseVersion as LV
from plinth import action_utils
CONFIG_FILE = '/etc/radicale/config'
DEFAULT_FILE = '/etc/default/radicale'
DEFAULT_FILE_DEPRECATED_VERSION = LV('2.1.10')
def parse_arguments():
@ -48,9 +51,14 @@ def parse_arguments():
def subcommand_setup(_):
"""Setup Radicale configuration."""
current_version = _get_version()
if not current_version:
print('Warning: Unable to get radicale version.')
aug = load_augeas()
aug.set('/files' + DEFAULT_FILE + '/ENABLE_RADICALE', 'yes')
if current_version and current_version < DEFAULT_FILE_DEPRECATED_VERSION:
aug.set('/files' + DEFAULT_FILE + '/ENABLE_RADICALE', 'yes')
aug.set('/files' + CONFIG_FILE + '/server/hosts',
'127.0.0.1:5232, [::1]:5232')
@ -64,6 +72,7 @@ def subcommand_setup(_):
aug.save()
action_utils.service_enable('radicale')
action_utils.service_restart('radicale')
action_utils.webserver_enable('radicale-plinth')
@ -89,6 +98,18 @@ def subcommand_disable(_):
action_utils.service_disable('radicale')
def _get_version():
try:
proc = subprocess.run(
['radicale', '--version'], stdout=subprocess.PIPE, check=True)
output = proc.stdout.decode('utf-8')
except subprocess.CalledProcessError:
return None
version = str(output.strip())
return LV(version)
def load_augeas():
"""Initialize Augeas."""
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +