mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
Service object to handle services on a system-level
The Service object now offers handling services on a system level, and gathering information whether it's enabled or running. New methods: enable, disable, is_enabled, is_running; For this it needs the correct (system-level) service name. All of the methods can be overridden/customized. This changes all modules to the new Service object and deletes action scripts that are not required anymore.
This commit is contained in:
1 parent
9fe49f881f
commit
a9528c56d9
30 files changed
+243
-629
No files matched your search
@@ -55,6 +55,8 @@ description = [
|
||||
|
||||
service = None
|
||||
|
||||
managed_services = ['repro']
|
||||
|
||||
|
||||
def init():
|
||||
"""Initialize the repro module."""
|
||||
@@ -63,8 +65,8 @@ def init():
|
||||
|
||||
global service
|
||||
service = service_module.Service(
|
||||
'repro', title, ['sip-plinth', 'sip-tls-plinth'], is_external=True,
|
||||
enabled=is_enabled())
|
||||
managed_services[0], title, ports=['sip-plinth', 'sip-tls-plinth'],
|
||||
is_external=True)
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
@@ -76,25 +78,16 @@ def setup(helper, old_version=None):
|
||||
|
||||
def get_status():
|
||||
"""Get the current service status."""
|
||||
return {'enabled': is_enabled(),
|
||||
'is_running': is_running()}
|
||||
|
||||
|
||||
def is_enabled():
|
||||
"""Return whether the service is enabled."""
|
||||
return action_utils.service_is_enabled('repro')
|
||||
|
||||
|
||||
def is_running():
|
||||
"""Return whether the service is running."""
|
||||
return action_utils.service_is_running('repro')
|
||||
return {'enabled': service.is_enabled(),
|
||||
'is_running': service.is_running()}
|
||||
|
||||
|
||||
def enable(should_enable):
|
||||
"""Enable/disable the module."""
|
||||
sub_command = 'enable' if should_enable else 'disable'
|
||||
actions.superuser_run('repro', [sub_command])
|
||||
service.notify_enabled(None, should_enable)
|
||||
if should_enable:
|
||||
service.enable()
|
||||
else:
|
||||
service.disable()
|
||||
|
||||
|
||||
def diagnose():
|
||||
|
||||
Reference in new issue
Block a user