mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-04 08:53:42 +00:00
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:
parent
6adec225d3
commit
1b4d42cd53
@ -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 +
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user