summaryrefslogtreecommitdiffstats
path: root/triggers/restart-services.trigger
diff options
context:
space:
mode:
Diffstat (limited to 'triggers/restart-services.trigger')
-rw-r--r--triggers/restart-services.trigger31
1 files changed, 21 insertions, 10 deletions
diff --git a/triggers/restart-services.trigger b/triggers/restart-services.trigger
index d586f46..6eac017 100644
--- a/triggers/restart-services.trigger
+++ b/triggers/restart-services.trigger
@@ -4,29 +4,40 @@ import cobbler.api as capi
import os
import sys
-#!/usr/bin/python
-
bootapi = capi.BootAPI()
settings = bootapi.settings()
manage_dhcp = str(settings.manage_dhcp).lower()
-manage_dhcp_mode = str(settings.manage_dhcp_mode).lower()
manage_dns = str(settings.manage_dns).lower()
+restart_dhcp = str(settings.restart_dhcp).lower()
+restart_dns = str(settings.restart_dns).lower()
omapi_enabled = settings.omapi_enabled
omapi_port = settings.omapi_port
+# load up our DHCP and DNS modules
+bootapi.get_sync()
+# bootapi.dhcp and bootapi.dns are now module references
+
+# special handling as we don't want to restart it twice
+has_restarted_dnsmasq = False
+
rc = 0
if manage_dhcp != "0":
- if manage_dhcp_mode == "isc":
- if not omapi_enabled:
+ if bootapi.dhcp.what() == "isc":
+ if not omapi_enabled and restart_dhcp:
rc = os.system("/sbin/service dhcpd restart")
- elif manage_dhcp_mode == "dnsmasq":
- rc = os.system("/sbin/service dnsmasq restart")
+ elif bootapi.dhcp.what() == "dnsmasq":
+ if restart_dhcp:
+ rc = os.system("/sbin/service dnsmasq restart")
+ has_restarted_dnsmasq = True
else:
- print "- error: unknown DHCP engine: %s" % manage_dhcp_mode
+ print "- error: unknown DHCP engine: %s" % bootapi.dhcp.what()
rc = 411
-if manage_dns != "0":
- rc = os.system("/sbin/service named restart")
+if manage_dns != "0" and restart_dns:
+ if bootapi.dns.what() == "bind":
+ rc = os.system("/sbin/service named restart")
+ elif bootapi.dns.what() == "dnsmasq" and not has_restarted_dnsmasq:
+ rc = os.ssytem("/sbin/service dnsmasq restart")
sys.exit(rc)