summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-07-30 07:27:25 +0200
committerChristian Poessinger <christian@poessinger.com>2021-07-30 07:28:15 +0200
commitf520182b56e34428e9d9491ba062025cc9bea971 (patch)
tree8beaa3e89286df34f3a7bb468652ca62a9b9cd55
parent65765fe95a34d81ad4a3aedb035936bbaf6a3f0e (diff)
downloadvyos-1x-f520182b56e34428e9d9491ba062025cc9bea971.tar.gz
vyos-1x-f520182b56e34428e9d9491ba062025cc9bea971.zip
vyos.util: add is_systemd_service_running() helper function
Test is a specified systemd service is actually running. Returns True if service is running, false otherwise.
-rw-r--r--python/vyos/util.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index d5cd46a6c..59f9f1c44 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -804,3 +804,9 @@ def make_incremental_progressbar(increment: float):
# Ignore further calls.
while True:
yield
+
+def is_systemd_service_running(service):
+ """ Test is a specified systemd service is actually running.
+ Returns True if service is running, false otherwise. """
+ tmp = run(f'systemctl is-active --quiet {service}')
+ return bool((tmp == 0))