mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Since radicale 1.x is only in Stretch (oldstable), remove code that was added to support that version and migration from 1.x to newer versions. Keep the fix for missing log path as the fix is not available in Buster yet. Tests: - Ran functional tests in testing container. Manually tested logging in to web interface and creating a calendar. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> [sunil: Add back the fix for missing log path] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
77 lines
2.0 KiB
Python
Executable File
77 lines
2.0 KiB
Python
Executable File
#!/usr/bin/python3
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Configuration helper for Radicale.
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
|
|
import augeas
|
|
|
|
from plinth import action_utils
|
|
|
|
CONFIG_FILE = '/etc/radicale/config'
|
|
LOG_PATH = '/var/log/radicale'
|
|
|
|
|
|
def parse_arguments():
|
|
"""Return parsed command line arguments as dictionary."""
|
|
parser = argparse.ArgumentParser()
|
|
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
|
|
|
configure = subparsers.add_parser('configure',
|
|
help='Configure various options')
|
|
configure.add_argument('--rights_type',
|
|
help='Set the rights type for radicale')
|
|
subparsers.add_parser('fix-paths', help='Ensure paths exists')
|
|
|
|
subparsers.required = True
|
|
return parser.parse_args()
|
|
|
|
|
|
def subcommand_configure(arguments):
|
|
"""Sets the radicale rights type to a particular value"""
|
|
if arguments.rights_type == 'owner_only':
|
|
# Default rights file is equivalent to owner_only.
|
|
arguments.rights_type = 'from_file'
|
|
|
|
aug = load_augeas()
|
|
aug.set('/files' + CONFIG_FILE + '/rights/type', arguments.rights_type)
|
|
aug.save()
|
|
|
|
action_utils.service_try_restart('uwsgi')
|
|
|
|
|
|
def subcommand_fix_paths(_):
|
|
"""Fix log path to work around a bug."""
|
|
# Workaround for bug in radicale's uwsgi script (#931201)
|
|
if not os.path.exists(LOG_PATH):
|
|
os.makedirs(LOG_PATH)
|
|
|
|
|
|
def load_augeas():
|
|
"""Initialize Augeas."""
|
|
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
|
augeas.Augeas.NO_MODL_AUTOLOAD)
|
|
|
|
# INI file lens
|
|
aug.set('/augeas/load/Puppet/lens', 'Puppet.lns')
|
|
aug.set('/augeas/load/Puppet/incl[last() + 1]', CONFIG_FILE)
|
|
|
|
aug.load()
|
|
return aug
|
|
|
|
|
|
def main():
|
|
"""Parse arguments and perform all duties."""
|
|
arguments = parse_arguments()
|
|
|
|
subcommand = arguments.subcommand.replace('-', '_')
|
|
subcommand_method = globals()['subcommand_' + subcommand]
|
|
subcommand_method(arguments)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|