diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-07-30 07:27:25 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-07-30 07:28:15 +0200 |
commit | f520182b56e34428e9d9491ba062025cc9bea971 (patch) | |
tree | 8beaa3e89286df34f3a7bb468652ca62a9b9cd55 /python | |
parent | 65765fe95a34d81ad4a3aedb035936bbaf6a3f0e (diff) | |
download | vyos-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.
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/util.py | 6 |
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)) |