From affffddf362fa274b7fa151344e949f5a44f36ea Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 26 Jan 2022 16:39:08 -0800 Subject: [PATCH] roundcube: Add setting for local connection only When this option is enabled, it would make the interface easy to work with. This is likely what most users would want. Don't break things for users who have already installed roundcube and ensure that local only is disable for them. Tests: - Install roundcube without the patch. Disable the app. Apply patch. Restart service. Notice that roundcube is not re-enabled. - Install roundcube without the patch. Apply patch. Restart service. Notice that roundcube configuration /etc/roundcube/config.inc.php file has been updated and include_once() at the end has been added. The file /etc/roundcube/freedombox-config.php has been added. Local only option is disabled. - Install roundcube freshly with the patch. Local only option is enabled. Open interface. Notice that server option is not presented. - Disable local only option and notice that server field is shown in the interface. Signed-off-by: Sunil Mohan Adapa [jvalleroy: Fix comment] Signed-off-by: James Valleroy Reviewed-by: James Valleroy --- actions/roundcube | 55 ++++++++++++++++++++++++++++ plinth/modules/roundcube/__init__.py | 22 ++++++++++- plinth/modules/roundcube/forms.py | 19 ++++++++++ plinth/modules/roundcube/urls.py | 5 +-- plinth/modules/roundcube/views.py | 34 +++++++++++++++++ 5 files changed, 130 insertions(+), 5 deletions(-) create mode 100644 plinth/modules/roundcube/forms.py create mode 100644 plinth/modules/roundcube/views.py diff --git a/actions/roundcube b/actions/roundcube index 890acb471..02f771d7e 100755 --- a/actions/roundcube +++ b/actions/roundcube @@ -5,9 +5,14 @@ Configuration helper for Roundcube server. """ import argparse +import json +import pathlib +import re from plinth import action_utils +_config_file = pathlib.Path('/etc/roundcube/freedombox-config.php') + def parse_arguments(): """Return parsed command line arguments as dictionary.""" @@ -16,6 +21,11 @@ def parse_arguments(): subparsers.add_parser('pre-install', help='Perform Roundcube pre-install configuration') + subparsers.add_parser('setup', help='Setup basic configuration') + subparsers.add_parser('get-config', help='Print current configuration') + subparser = subparsers.add_parser('set-config', help='Set configuration') + subparser.add_argument('--local-only', choices=['True', 'False'], + help='Set current configuration') subparsers.required = True return parser.parse_args() @@ -29,6 +39,51 @@ def subcommand_pre_install(_): ]) +def subcommand_setup(_): + """Add FreedomBox configuration and include from main configuration.""" + if not _config_file.exists(): + _config_file.write_text('