mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
syncthing: Fixes issues with enabling and setup
- On enable, don't just run syncthing, actually enable it. - Make setup step idempotent. Run setup during enable as it is idempotent. - Perform user/group creation properly during setup. - Provide better description. - Modify the application label and icon for accuracy of the service provided. - Fix problem with showing service in firewall.
This commit is contained in:
2 files changed
+57
-36
No files matched your search
@@ -26,30 +26,43 @@ from plinth import action_utils
|
||||
from plinth import cfg
|
||||
from plinth import frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
|
||||
version = 1
|
||||
|
||||
depends = ['apps']
|
||||
|
||||
managed_services = ['syncthing@syncthing.service']
|
||||
managed_services = ['syncthing']
|
||||
|
||||
managed_packages = ['syncthing']
|
||||
|
||||
title = _('Personal Cloud (Syncthing)')
|
||||
title = _('File Synchronization (Syncthing)')
|
||||
|
||||
description = [
|
||||
_('Syncthing is a file synchronization program that can sync files '
|
||||
'between multiple devices. Syncthing enables this FreedomBox to be '
|
||||
'used as a cloud server for storing and sharing files'),
|
||||
_('Syncthing is an application that can synchronizes files across '
|
||||
'multiple devices. Creation, modification and deletion of files on one '
|
||||
'device will automatically be replicated to other devices.'),
|
||||
format_lazy(
|
||||
_('Running Synching on {box_name}, provides an extra synchronization '
|
||||
'point for your data that is available most of the time so that '
|
||||
'your devices synchronize more often. On {box_name}, a single '
|
||||
'instance of Syncthing runs and may be used by many users. Each '
|
||||
'user\'s set of devices many be synchronized with a distinct set '
|
||||
'of folders. Web interface is only available for users '
|
||||
'belonging to the "admin" group.'), box_name=_(cfg.box_name)),
|
||||
_('When enabled, Syncthing will be available from <a href="/syncthing/">'
|
||||
'/syncthing</a> path on the web server.'),
|
||||
'/syncthing</a> web interface. Desktop and mobile clients are also '
|
||||
'<a href="https://syncthing.net/">available.</a>'),
|
||||
]
|
||||
|
||||
service = None
|
||||
|
||||
|
||||
def init():
|
||||
"""Intialize the module."""
|
||||
menu = cfg.main_menu.get('apps:index')
|
||||
menu.add_urlname(title, 'glyphicon-cloud', 'syncthing:index')
|
||||
menu.add_urlname(title, 'glyphicon-refresh', 'syncthing:index')
|
||||
|
||||
global service
|
||||
setup_helper = globals()['setup_helper']
|
||||
@@ -61,7 +74,8 @@ def init():
|
||||
is_external=True,
|
||||
is_enabled=is_enabled,
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
disable=disable,
|
||||
is_running=is_running)
|
||||
|
||||
if is_enabled():
|
||||
add_shortcut()
|
||||
@@ -69,9 +83,8 @@ def init():
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
helper.call('pre', actions.superuser_run, 'syncthing', ['pre-setup'])
|
||||
helper.install(managed_packages)
|
||||
helper.call('post', actions.superuser_run, 'syncthing', ['setup'])
|
||||
helper.call('post', actions.superuser_run, 'syncthing', ['enable'])
|
||||
global service
|
||||
if service is None:
|
||||
service = service_module.Service(
|
||||
@@ -81,7 +94,8 @@ def setup(helper, old_version=None):
|
||||
is_external=True,
|
||||
is_enabled=is_enabled,
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
disable=disable,
|
||||
is_running=is_running)
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
@@ -92,6 +106,11 @@ def add_shortcut():
|
||||
'syncthing', title, url='/syncthing/', login_required=True)
|
||||
|
||||
|
||||
def is_running():
|
||||
"""Return whether the service is running."""
|
||||
return action_utils.service_is_running('syncthing@syncthing')
|
||||
|
||||
|
||||
def is_enabled():
|
||||
"""Return whether the module is enabled."""
|
||||
return (action_utils.service_is_enabled('syncthing@syncthing') and
|
||||
|
||||
Reference in new issue
Block a user