From 1e7b1b8ba5a982ca801a4d8246934a2315dd5931 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 25 Jun 2008 14:58:20 -0400 Subject: Remove references to manage_dhcp_mode and manage_dns_mode as this is governed by modules.conf, and rewrite the restart-services trigger to understand restart_dhcp and restart_dns variables, which are now mentioned in the settings file. Also, clean up the tests so they work more nicely on F9, and remove some unused lines from the Makefile. --- triggers/restart-services.trigger | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'triggers/restart-services.trigger') 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) -- cgit