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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2021-12-13 19:13:31 -08:00 committed by James Valleroy
parent 57295ae893
commit 84f12d8633
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 17 additions and 32 deletions

View File

@ -5,12 +5,9 @@ Configuration helper for Roundcube server.
""" """
import argparse import argparse
import re
from plinth import action_utils from plinth import action_utils
APACHE_CONF = '/etc/apache2/conf-available/roundcube.conf'
def parse_arguments(): def parse_arguments():
"""Return parsed command line arguments as dictionary.""" """Return parsed command line arguments as dictionary."""
@ -19,8 +16,6 @@ def parse_arguments():
subparsers.add_parser('pre-install', subparsers.add_parser('pre-install',
help='Perform Roundcube pre-install configuration') help='Perform Roundcube pre-install configuration')
subparsers.add_parser('setup',
help='Perform Roundcube configuration setup')
subparsers.required = True subparsers.required = True
return parser.parse_args() 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(): def main():
"""Parse arguments and perform all duties.""" """Parse arguments and perform all duties."""
arguments = parse_arguments() arguments = parse_arguments()

View File

@ -12,7 +12,6 @@ from plinth.modules.apache.components import Webserver
from plinth.modules.backups.components import BackupRestore from plinth.modules.backups.components import BackupRestore
from plinth.modules.firewall.components import Firewall from plinth.modules.firewall.components import Firewall
from plinth.package import Packages from plinth.package import Packages
from plinth.utils import Version
from . import manifest from . import manifest
@ -69,15 +68,20 @@ class RoundcubeApp(app_module.App):
login_required=True) login_required=True)
self.add(shortcut) self.add(shortcut)
packages = Packages('packages-roundcube', packages = Packages(
['sqlite3', 'roundcube', 'roundcube-sqlite3']) 'packages-roundcube',
['sqlite3', 'roundcube', 'roundcube-core', 'roundcube-sqlite3'])
self.add(packages) self.add(packages)
firewall = Firewall('firewall-roundcube', info.name, firewall = Firewall('firewall-roundcube', info.name,
ports=['http', 'https'], is_external=True) ports=['http', 'https'], is_external=True)
self.add(firewall) 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']) urls=['https://{host}/roundcube'])
self.add(webserver) self.add(webserver)
@ -90,7 +94,6 @@ def setup(helper, old_version=None):
"""Install and configure the module.""" """Install and configure the module."""
helper.call('pre', actions.superuser_run, 'roundcube', ['pre-install']) helper.call('pre', actions.superuser_run, 'roundcube', ['pre-install'])
app.setup(old_version) app.setup(old_version)
helper.call('post', actions.superuser_run, 'roundcube', ['setup'])
helper.call('post', app.enable) helper.call('post', app.enable)
@ -99,11 +102,10 @@ def force_upgrade(helper, packages):
if 'roundcube-core' not in packages: if 'roundcube-core' not in packages:
return False return False
# Allow roundcube any lower version to upgrade to 1.4.* # Allow roundcube any version to upgrade to any version. This is okay
package = packages['roundcube-core'] # because there will no longer be conflicting file changes.
if Version(package['new_version']) > Version('1.5~'):
return False
helper.install(['roundcube-core'], force_configuration='new') 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 return True

View File

@ -0,0 +1,4 @@
##
## Add alias to /roundcube that the roundcube.conf doesn't do.
##
Alias /roundcube /var/lib/roundcube/public_html