mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-08 11:40:25 +00:00
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:
parent
57295ae893
commit
84f12d8633
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
##
|
||||
## Add alias to /roundcube that the roundcube.conf doesn't do.
|
||||
##
|
||||
Alias /roundcube /var/lib/roundcube/public_html
|
||||
Loading…
x
Reference in New Issue
Block a user