diff --git a/actions/roundcube b/actions/roundcube index 08ab5bb20..bf1e48a05 100755 --- a/actions/roundcube +++ b/actions/roundcube @@ -29,7 +29,6 @@ from plinth import action_utils APACHE_CONF = '/etc/apache2/conf-available/roundcube.conf' -APACHE_ENABLED_CONF = '/etc/apache2/conf-enabled/roundcube.conf' def parse_arguments(): @@ -41,8 +40,6 @@ def parse_arguments(): help='Perform Roundcube pre-install configuration') subparsers.add_parser('setup', help='Perform Roundcube configuration setup') - subparsers.add_parser('get-enabled', - help='Get whether Roundcube service is enabled') subparsers.add_parser('enable', help='Enable Roundcube') subparsers.add_parser('disable', help='Disable Roundcube') @@ -75,25 +72,14 @@ def subcommand_setup(_): action_utils.service_reload('apache2') -def subcommand_get_enabled(_): - """Get whether service is enabled.""" - try: - subprocess.check_output(['a2query', '-c', 'roundcube']) - print('yes') - except subprocess.CalledProcessError: - print('no') - - def subcommand_enable(_): - """Start service.""" - subprocess.call(['a2enconf', 'roundcube']) - action_utils.service_reload('apache2') + """Enable web configuration and reload.""" + action_utils.webserver_enable('roundcube') def subcommand_disable(_): - """Stop service.""" - subprocess.call(['a2disconf', 'roundcube']) - action_utils.service_reload('apache2') + """Disable web configuration and reload.""" + action_utils.webserver_disable('roundcube') def main(): diff --git a/plinth/modules/roundcube/__init__.py b/plinth/modules/roundcube/__init__.py index dd34c8a47..56077af59 100644 --- a/plinth/modules/roundcube/__init__.py +++ b/plinth/modules/roundcube/__init__.py @@ -22,6 +22,7 @@ Plinth module to configure Roundcube. from gettext import gettext as _ from plinth import actions +from plinth import action_utils from plinth import cfg from plinth import service as service_module @@ -34,3 +35,7 @@ def init(): menu = cfg.main_menu.get('apps:index') menu.add_urlname(_('Email Client (Roundcube)'), 'glyphicon-envelope', 'roundcube:index', 50) + +def is_enabled(): + """Return whether the module is enabled.""" + return action_utils.webserver_is_enabled('roundcube') diff --git a/plinth/modules/roundcube/views.py b/plinth/modules/roundcube/views.py index 9a7d8a162..3da58c495 100644 --- a/plinth/modules/roundcube/views.py +++ b/plinth/modules/roundcube/views.py @@ -27,6 +27,7 @@ import logging from .forms import RoundcubeForm from plinth import actions from plinth import package +from plinth.modules import roundcube logger = logging.getLogger(__name__) @@ -67,10 +68,7 @@ def index(request): def get_status(): """Get the current status.""" - output = actions.run('roundcube', ['get-enabled']) - enabled = (output.strip() == 'yes') - - return {'enabled': enabled} + return {'enabled': roundcube.is_enabled()} def _apply_changes(request, old_status, new_status):