diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-07-30 20:19:10 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-07-30 20:19:10 +0200 |
commit | ec713e585ace09beb9942d928e0099a35dcdd0f2 (patch) | |
tree | e19dd2d90d1762a9ae8983f7aa3a00669fe0cda4 /src/conf_mode | |
parent | f520182b56e34428e9d9491ba062025cc9bea971 (diff) | |
download | vyos-1x-ec713e585ace09beb9942d928e0099a35dcdd0f2.tar.gz vyos-1x-ec713e585ace09beb9942d928e0099a35dcdd0f2.zip |
vyos.util: drop custom implementations in favor of is_systemd_service_running()
Commit f520182b ("vyos.util: add is_systemd_service_running() helper function")
added a new helper function that can be used to check if a systemd service is
running.
Drop all custom implementations in favor of this library call.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/le_cert.py | 4 | ||||
-rwxr-xr-x | src/conf_mode/system-option.py | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/conf_mode/le_cert.py b/src/conf_mode/le_cert.py index 755c89966..6e169a3d5 100755 --- a/src/conf_mode/le_cert.py +++ b/src/conf_mode/le_cert.py @@ -22,6 +22,7 @@ from vyos.config import Config from vyos import ConfigError from vyos.util import cmd from vyos.util import call +from vyos.util import is_systemd_service_running from vyos import airbag airbag.enable() @@ -87,8 +88,7 @@ def generate(cert): # certbot will attempt to reload nginx, even with 'certonly'; # start nginx if not active - ret = call('systemctl is-active --quiet nginx.service') - if ret: + if not is_systemd_service_running('nginx.service'): call('systemctl start nginx.service') request_certbot(cert) diff --git a/src/conf_mode/system-option.py b/src/conf_mode/system-option.py index 454611c55..55cf6b142 100755 --- a/src/conf_mode/system-option.py +++ b/src/conf_mode/system-option.py @@ -24,6 +24,7 @@ from vyos.config import Config from vyos.configdict import dict_merge from vyos.template import render from vyos.util import cmd +from vyos.util import is_systemd_service_running from vyos.validate import is_addr_assigned from vyos.xml import defaults from vyos import ConfigError @@ -114,7 +115,7 @@ def apply(options): if 'performance' in options: cmd('systemctl restart tuned.service') # wait until daemon has started before sending configuration - while (int(os.system('systemctl is-active --quiet tuned.service')) != 0): + while (not is_systemd_service_running('tuned.service')): sleep(0.250) cmd('tuned-adm profile network-{performance}'.format(**options)) else: |