Commit c4cb649e authored by pa's avatar pa

only restart isc-dhcp-server if it is already running

parent c23833a4
......@@ -49,9 +49,12 @@ def regen_dhcp(api_client):
def reload_server():
"""Relance le serveur DHCP."""
try:
subprocess.check_output(
['/bin/systemctl', 'restart', 'isc-dhcp-server'],
stderr=subprocess.STDOUT)
is_running = subprocess.run(
['/bin/systemctl', 'status', 'isc-dhcp-server']).returncode
if is_running == 0:
subprocess.check_output(
['/bin/systemctl', 'restart', 'isc-dhcp-server'],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as err:
print(
"Erreur lors du redémarrage de isc-dhcp-server.\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment