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 <sunil@medhas.org>
[jvalleroy: Fix comment]
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2022-01-31 18:46:01 -05:00
1 parent 9a2d66c62f
commit affffddf36
5 files changed
+130 -5

No files matched your search

+20 -2
View File
@@ -3,6 +3,8 @@
FreedomBox app to configure Roundcube.
"""
import json
from django.utils.translation import gettext_lazy as _
from plinth import actions
@@ -42,7 +44,7 @@ class RoundcubeApp(app_module.App):
app_id = 'roundcube'
_version = 1
_version = 2
def __init__(self):
"""Create components for the app."""
@@ -94,7 +96,10 @@ 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', app.enable)
helper.call('post', actions.superuser_run, 'roundcube', ['setup'])
if old_version == 0:
set_config(local_only=True)
helper.call('post', app.enable)
def force_upgrade(helper, packages):
@@ -109,3 +114,16 @@ def force_upgrade(helper, packages):
app.get_component('webserver-roundcube-freedombox').enable()
return True
def get_config():
"""Return Rouncube configuration."""
value = actions.superuser_run('roundcube', ['get-config'])
return json.loads(value)
def set_config(local_only):
"""Set whether only local server should be allowed."""
actions.superuser_run('roundcube',
['set-config', '--local-only',
str(local_only)])