From 84f12d863315a4ed8a01c17fd7f108ad99b547c4 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 13 Dec 2021 19:13:31 -0800 Subject: [PATCH] roundcube: Allow upgrades using configuration file prompts Closes: #2159. Ship a separate Apache configuration file instead of editing the one provided by roundcube package. This avoids configuration file prompt when roundcube package needs to be upgraded. Tests: - Freshly install roundcube package 1.4.x (using apt preferences and Bullseye), run functional tests and login to a gmail account. - Freshly install roundcube package 1.5.x (from testing), run functional tests and login to a gmail account. - Install roundcube 1.4.x version on testing container without these changes. After applying these changes, run 'apt update' while roundcube is enabled and let FreedomBox upgrade roundcube to 1.5.x version. After this, run functional tests and login to a gmail account. - Repeat the previous test with upgrade while rouncube is disabled. Then enable rouncube, run functional tests and login to gmail account. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- actions/roundcube | 21 ---------------- plinth/modules/roundcube/__init__.py | 24 ++++++++++--------- .../conf-available/roundcube-freedombox.conf | 4 ++++ 3 files changed, 17 insertions(+), 32 deletions(-) create mode 100644 plinth/modules/roundcube/data/etc/apache2/conf-available/roundcube-freedombox.conf diff --git a/actions/roundcube b/actions/roundcube index 91b223659..890acb471 100755 --- a/actions/roundcube +++ b/actions/roundcube @@ -5,12 +5,9 @@ Configuration helper for Roundcube server. """ import argparse -import re from plinth import action_utils -APACHE_CONF = '/etc/apache2/conf-available/roundcube.conf' - def parse_arguments(): """Return parsed command line arguments as dictionary.""" @@ -19,8 +16,6 @@ def parse_arguments(): subparsers.add_parser('pre-install', help='Perform Roundcube pre-install configuration') - subparsers.add_parser('setup', - help='Perform Roundcube configuration setup') subparsers.required = True return parser.parse_args() @@ -34,22 +29,6 @@ def subcommand_pre_install(_): ]) -def subcommand_setup(_): - """Setup Roundcube Apache configuration.""" - with open(APACHE_CONF, 'r') as conffile: - lines = conffile.readlines() - - with open(APACHE_CONF, 'w') as conffile: - for line in lines: - match = re.match(r'#\s*(Alias /roundcube.*)', line) - if match: - conffile.write(match.group(1) + '\n') - else: - conffile.write(line) - - action_utils.service_reload('apache2') - - def main(): """Parse arguments and perform all duties.""" arguments = parse_arguments() diff --git a/plinth/modules/roundcube/__init__.py b/plinth/modules/roundcube/__init__.py index 49997b7dc..e53554b6d 100644 --- a/plinth/modules/roundcube/__init__.py +++ b/plinth/modules/roundcube/__init__.py @@ -12,7 +12,6 @@ from plinth.modules.apache.components import Webserver from plinth.modules.backups.components import BackupRestore from plinth.modules.firewall.components import Firewall from plinth.package import Packages -from plinth.utils import Version from . import manifest @@ -69,15 +68,20 @@ class RoundcubeApp(app_module.App): login_required=True) self.add(shortcut) - packages = Packages('packages-roundcube', - ['sqlite3', 'roundcube', 'roundcube-sqlite3']) + packages = Packages( + 'packages-roundcube', + ['sqlite3', 'roundcube', 'roundcube-core', 'roundcube-sqlite3']) self.add(packages) firewall = Firewall('firewall-roundcube', info.name, ports=['http', 'https'], is_external=True) self.add(firewall) - webserver = Webserver('webserver-roundcube', 'roundcube', + webserver = Webserver('webserver-roundcube', 'roundcube') + self.add(webserver) + + webserver = Webserver('webserver-roundcube-freedombox', + 'roundcube-freedombox', urls=['https://{host}/roundcube']) self.add(webserver) @@ -90,7 +94,6 @@ def setup(helper, old_version=None): """Install and configure the module.""" helper.call('pre', actions.superuser_run, 'roundcube', ['pre-install']) app.setup(old_version) - helper.call('post', actions.superuser_run, 'roundcube', ['setup']) helper.call('post', app.enable) @@ -99,11 +102,10 @@ def force_upgrade(helper, packages): if 'roundcube-core' not in packages: return False - # Allow roundcube any lower version to upgrade to 1.4.* - package = packages['roundcube-core'] - if Version(package['new_version']) > Version('1.5~'): - return False - + # Allow roundcube any version to upgrade to any version. This is okay + # because there will no longer be conflicting file changes. helper.install(['roundcube-core'], force_configuration='new') - actions.superuser_run('roundcube', ['setup']) + if app.get_component('webserver-roundcube').is_enabled(): + app.get_component('webserver-roundcube-freedombox').enable() + return True diff --git a/plinth/modules/roundcube/data/etc/apache2/conf-available/roundcube-freedombox.conf b/plinth/modules/roundcube/data/etc/apache2/conf-available/roundcube-freedombox.conf new file mode 100644 index 000000000..545a922f1 --- /dev/null +++ b/plinth/modules/roundcube/data/etc/apache2/conf-available/roundcube-freedombox.conf @@ -0,0 +1,4 @@ +## +## Add alias to /roundcube that the roundcube.conf doesn't do. +## +Alias /roundcube /var/lib/roundcube/public_html