From b234d0e1b33c09c4b588b00aaa49e84cb9c5bca9 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sun, 4 Dec 2016 13:27:35 -0500 Subject: [PATCH] Ensure that services are registered when modules complete setup --- plinth/modules/datetime/__init__.py | 4 ++++ plinth/modules/deluge/__init__.py | 6 ++++++ plinth/modules/ikiwiki/__init__.py | 5 +++++ plinth/modules/minetest/__init__.py | 6 ++++++ plinth/modules/mumble/__init__.py | 6 ++++++ plinth/modules/openvpn/__init__.py | 4 ++++ plinth/modules/owncloud/__init__.py | 5 +++++ plinth/modules/privoxy/__init__.py | 6 ++++++ plinth/modules/quassel/__init__.py | 5 +++++ plinth/modules/radicale/__init__.py | 6 ++++++ plinth/modules/repro/__init__.py | 6 ++++++ plinth/modules/restore/__init__.py | 5 +++++ plinth/modules/roundcube/__init__.py | 5 +++++ plinth/modules/shaarli/__init__.py | 5 +++++ plinth/modules/tor/__init__.py | 16 ++++++++++++++++ plinth/modules/transmission/__init__.py | 6 ++++++ plinth/modules/ttrss/__init__.py | 6 ++++++ plinth/modules/xmpp/__init__.py | 7 +++++++ 18 files changed, 109 insertions(+) diff --git a/plinth/modules/datetime/__init__.py b/plinth/modules/datetime/__init__.py index 86898e742..0f0944cf4 100644 --- a/plinth/modules/datetime/__init__.py +++ b/plinth/modules/datetime/__init__.py @@ -61,6 +61,10 @@ def init(): def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['ntp'], is_external=False) helper.call('post', service.notify_enabled, None, True) diff --git a/plinth/modules/deluge/__init__.py b/plinth/modules/deluge/__init__.py index 681242c7a..8caa9ee5c 100644 --- a/plinth/modules/deluge/__init__.py +++ b/plinth/modules/deluge/__init__.py @@ -71,6 +71,12 @@ def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) helper.call('post', actions.superuser_run, 'deluge', ['enable']) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['http', 'https'], + is_external=True, is_enabled=is_enabled, enable=enable, + disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/ikiwiki/__init__.py b/plinth/modules/ikiwiki/__init__.py index 8f0ae8afa..0e9d516d2 100644 --- a/plinth/modules/ikiwiki/__init__.py +++ b/plinth/modules/ikiwiki/__init__.py @@ -69,6 +69,11 @@ def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) helper.call('post', actions.superuser_run, 'ikiwiki', ['setup']) + global service + if service is None: + service = service_module.Service( + 'ikiwiki', title, ports=['http', 'https'], is_external=True, + is_enabled=is_enabled, enable=enable, disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcuts) diff --git a/plinth/modules/minetest/__init__.py b/plinth/modules/minetest/__init__.py index f4246eb09..1643a275f 100644 --- a/plinth/modules/minetest/__init__.py +++ b/plinth/modules/minetest/__init__.py @@ -78,6 +78,12 @@ def init(): def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, + ports=['minetest-plinth'], is_external=True, enable=enable, + disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/mumble/__init__.py b/plinth/modules/mumble/__init__.py index 26cf670b4..f63c7088c 100644 --- a/plinth/modules/mumble/__init__.py +++ b/plinth/modules/mumble/__init__.py @@ -78,6 +78,12 @@ class MumbleServiceView(ServiceView): def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['mumble-plinth'], + is_external=True, + enable=enable, disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/openvpn/__init__.py b/plinth/modules/openvpn/__init__.py index a009e35cf..137e2820e 100644 --- a/plinth/modules/openvpn/__init__.py +++ b/plinth/modules/openvpn/__init__.py @@ -67,6 +67,10 @@ def init(): def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['openvpn'], is_external=True) def is_setup(): diff --git a/plinth/modules/owncloud/__init__.py b/plinth/modules/owncloud/__init__.py index f7fff7d07..9bb344341 100644 --- a/plinth/modules/owncloud/__init__.py +++ b/plinth/modules/owncloud/__init__.py @@ -77,6 +77,11 @@ def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) helper.call('post', actions.superuser_run, 'owncloud-setup', ['enable']) + global service + if service is None: + service = service_module.Service( + 'owncloud', title, ports=['http', 'https'], is_external=True, + is_enabled=is_enabled, enable=_enable, disable=_disable) helper.call('post', service.notify_enabled, None, True) diff --git a/plinth/modules/privoxy/__init__.py b/plinth/modules/privoxy/__init__.py index 54cc70be0..e86c88377 100644 --- a/plinth/modules/privoxy/__init__.py +++ b/plinth/modules/privoxy/__init__.py @@ -83,6 +83,12 @@ def setup(helper, old_version=None): """Install and configure the module.""" helper.call('pre', actions.superuser_run, 'privoxy', ['pre-install']) helper.install(managed_packages) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['privoxy'], + is_external=False, + enable=enable, disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/quassel/__init__.py b/plinth/modules/quassel/__init__.py index 44d2d4716..086766ad5 100644 --- a/plinth/modules/quassel/__init__.py +++ b/plinth/modules/quassel/__init__.py @@ -85,6 +85,11 @@ class QuasselServiceView(ServiceView): def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['quassel-plinth'], + is_external=True, enable=enable, disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/radicale/__init__.py b/plinth/modules/radicale/__init__.py index dcd3acf5e..5f3a0733b 100644 --- a/plinth/modules/radicale/__init__.py +++ b/plinth/modules/radicale/__init__.py @@ -76,6 +76,12 @@ def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) helper.call('post', actions.superuser_run, 'radicale', ['setup']) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['http', 'https'], + is_external=True, + enable=enable, disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/repro/__init__.py b/plinth/modules/repro/__init__.py index f85a6699a..95d6c1882 100644 --- a/plinth/modules/repro/__init__.py +++ b/plinth/modules/repro/__init__.py @@ -90,6 +90,12 @@ def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) helper.call('post', actions.superuser_run, 'repro', ['setup']) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, + ports=['sip', 'sips', 'rtp-plinth'], + is_external=True, enable=enable, disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/restore/__init__.py b/plinth/modules/restore/__init__.py index 49726f697..88beea423 100644 --- a/plinth/modules/restore/__init__.py +++ b/plinth/modules/restore/__init__.py @@ -68,3 +68,8 @@ def init(): def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['http', 'https'], + is_external=False) diff --git a/plinth/modules/roundcube/__init__.py b/plinth/modules/roundcube/__init__.py index 6d3c9dc86..6e225af85 100644 --- a/plinth/modules/roundcube/__init__.py +++ b/plinth/modules/roundcube/__init__.py @@ -83,6 +83,11 @@ def setup(helper, old_version=None): helper.install(managed_packages) helper.call('post', actions.superuser_run, 'roundcube', ['setup']) helper.call('post', add_shortcut) + global service + if service is None: + service = service_module.Service( + 'roundcube', title, ports=['http', 'https'], is_external=True, + is_enabled=is_enabled, enable=enable, disable=disable) def add_shortcut(): diff --git a/plinth/modules/shaarli/__init__.py b/plinth/modules/shaarli/__init__.py index 9f749744a..d6171b407 100644 --- a/plinth/modules/shaarli/__init__.py +++ b/plinth/modules/shaarli/__init__.py @@ -67,6 +67,11 @@ def init(): def setup(helper, old_version=None): """Install and configure the module.""" helper.install(managed_packages) + global service + if service is None: + service = service_module.Service( + 'shaarli', title, ports=['http', 'https'], is_external=True, + is_enabled=is_enabled, enable=enable, disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/tor/__init__.py b/plinth/modules/tor/__init__.py index ebb57ee79..7194a0e62 100644 --- a/plinth/modules/tor/__init__.py +++ b/plinth/modules/tor/__init__.py @@ -103,8 +103,24 @@ def setup(helper, old_version=None): helper.call('post', actions.superuser_run, 'tor', ['setup']) helper.call('post', actions.superuser_run, 'tor', ['configure', '--apt-transport-tor', 'enable']) + + global socks_service + if socks_service is None: + socks_service = service_module.Service( + 'tor-socks', _('Tor Anonymity Network'), ports=['tor-socks'], + is_external=False, is_enabled=utils.is_enabled, + is_running=utils.is_running) helper.call('post', socks_service.notify_enabled, None, True) + + global bridge_service + if bridge_service is None: + bridge_service = service_module.Service( + 'tor-bridge', _('Tor Bridge Relay'), + ports=['tor-orport', 'tor-obfs3', 'tor-obfs4'], + is_external=True, is_enabled=utils.is_enabled, + is_running=utils.is_running) helper.call('post', bridge_service.notify_enabled, None, True) + helper.call('post', update_hidden_service_domain) diff --git a/plinth/modules/transmission/__init__.py b/plinth/modules/transmission/__init__.py index c60c51ee7..d46215a20 100644 --- a/plinth/modules/transmission/__init__.py +++ b/plinth/modules/transmission/__init__.py @@ -76,6 +76,12 @@ def setup(helper, old_version=None): input=json.dumps(new_configuration).encode()) helper.call('post', actions.superuser_run, 'transmission', ['enable']) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['http', 'https'], + is_external=True, is_enabled=is_enabled, + enable=enable, disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/ttrss/__init__.py b/plinth/modules/ttrss/__init__.py index b545cfc4d..25b63b7eb 100644 --- a/plinth/modules/ttrss/__init__.py +++ b/plinth/modules/ttrss/__init__.py @@ -72,6 +72,12 @@ def setup(helper, old_version=None): helper.call('pre', actions.superuser_run, 'ttrss', ['pre-setup']) helper.install(managed_packages) helper.call('post', actions.superuser_run, 'ttrss', ['setup']) + global service + if service is None: + service = service_module.Service( + managed_services[0], title, ports=['http', 'https'], + is_external=True, + is_enabled=is_enabled, enable=enable, disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut) diff --git a/plinth/modules/xmpp/__init__.py b/plinth/modules/xmpp/__init__.py index 90003254f..410234cfe 100644 --- a/plinth/modules/xmpp/__init__.py +++ b/plinth/modules/xmpp/__init__.py @@ -88,6 +88,13 @@ def setup(helper, old_version=None): ['pre-install', '--domainname', domainname]) helper.install(managed_packages) helper.call('post', actions.superuser_run, 'xmpp', ['setup']) + global service + if service is None: + service = service_module.Service( + 'ejabberd', title, + ports=['xmpp-client', 'xmpp-server', 'xmpp-bosh'], + is_external=True, is_enabled=is_enabled, enable=enable, + disable=disable) helper.call('post', service.notify_enabled, None, True) helper.call('post', add_shortcut)