Removed chp service

This commit is contained in:
GeorgianaElena
2019-02-18 15:08:53 +02:00
parent ffa635dda3
commit 84d8000114
3 changed files with 59 additions and 11 deletions

View File

@@ -48,6 +48,17 @@ def start_service(name):
], check=True)
def stop_service(name):
"""
Start service with given name.
"""
subprocess.run([
'systemctl',
'stop',
name
], check=True)
def restart_service(name):
"""
Restart service with given name.
@@ -72,6 +83,19 @@ def enable_service(name):
], check=True)
def disable_service(name):
"""
Enable a service with given name.
This most likely makes the service start on bootup
"""
subprocess.run([
'systemctl',
'disable',
name
], check=True)
def check_service_active(name):
"""
Check if a service is currently active (running)
@@ -85,3 +109,17 @@ def check_service_active(name):
return True
except subprocess.CalledProcessError:
return False
def check_service_enabled(name):
"""
Check if a service is enabled
"""
try:
subprocess.run([
'systemctl',
'is-enabled',
name
], check=True)
return True
except subprocess.CalledProcessError:
return False