From 53645deebf1e22a6f08bd6426e69ebdb4e352b5a Mon Sep 17 00:00:00 2001 From: Joseph Nuthalpati Date: Fri, 17 Mar 2017 22:07:23 +0530 Subject: [PATCH] syncthing: Made it a systemd service --- actions/syncthing | 19 +++++++++++++++---- plinth/modules/syncthing/__init__.py | 4 +++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/actions/syncthing b/actions/syncthing index f3a4a3677..33282a78c 100755 --- a/actions/syncthing +++ b/actions/syncthing @@ -21,7 +21,6 @@ Configuration helper for Syncthing. """ import argparse -import augeas import subprocess from plinth import action_utils @@ -42,20 +41,32 @@ def parse_arguments(): def subcommand_setup(_): """Setup Syncthing configuration.""" - action_utils.service_restart('syncthing') + subprocess.check_call( + ['cp', '/lib/systemd/system/syncthing@.service', '/etc/systemd']) + service_enable() action_utils.webserver_enable('syncthing-plinth') +def service_enable(): + """Start the Syncthing service as plinth user""" + subprocess.check_call(['systemctl', 'start', 'syncthing@plinth.service']) + + +def service_disable(): + """Stop the Syncthing service as plinth user""" + subprocess.check_call(['systemctl', 'stop', 'syncthing@plinth.service']) + + def subcommand_enable(_): """Enable web configuration and reload.""" - action_utils.service_enable('syncthing') + service_enable() action_utils.webserver_enable('syncthing-plinth') def subcommand_disable(_): """Disable web configuration and reload.""" action_utils.webserver_disable('syncthing-plinth') - action_utils.service_disable('syncthing') + service_disable() def main(): diff --git a/plinth/modules/syncthing/__init__.py b/plinth/modules/syncthing/__init__.py index 7e6feea37..33fd0c778 100644 --- a/plinth/modules/syncthing/__init__.py +++ b/plinth/modules/syncthing/__init__.py @@ -18,6 +18,8 @@ Plinth module to configure Syncthing. """ +import subprocess + from django.utils.translation import ugettext_lazy as _ from plinth import actions @@ -93,7 +95,7 @@ def add_shortcut(): def is_enabled(): """Return whether the module is enabled.""" - return (action_utils.service_is_enabled('syncthing') and + return (action_utils.service_is_enabled('syncthing@plinth.service') and action_utils.webserver_is_enabled('syncthing-plinth'))