From 1b1222ec7f95a773fcab39bf1ebe68da198919be Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Fri, 19 Oct 2007 16:44:06 -0400 Subject: Service restarting has been abstracted out of the action_sync code, and is now a trigger. This commit adds pre/post sync triggers, for scripting of arbitrary actions. The idea is that a cobbler user can now modify the restart-services script to rsync DHCP configurations to a remote box and instead restart them there, for hosting DHCP on a different box. Or do anything else that might be required. The restart-services trigger will ship in the cobbler RPM. Users can modify it at will and it is marked as config(noreplace) so upgrades will not affect it. --- triggers/restart-services.trigger | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 triggers/restart-services.trigger (limited to 'triggers') diff --git a/triggers/restart-services.trigger b/triggers/restart-services.trigger new file mode 100644 index 0000000..98d478b --- /dev/null +++ b/triggers/restart-services.trigger @@ -0,0 +1,21 @@ +#!/usr/bin/python + +import cobbler.api as capi +import os +import sys + +bootapi = capi.BootAPI() +settings = bootapi.settings() +manage_dhcp = str(settings.manage_dhcp).lower() +manage_dhcp_mode = str(settings.manage_dhcp_mode).lower() + +if manage_dhcp != "0": + if manage_dhcp_mode == "isc": + rc = os.system("/sbin/service dhcpd restart") + elif manage_dhcp_mode == "dnsmasq": + rc = os.system("/sbin/service dnsmasq restart") + else: + print "- error: unknown DHCP engine: %s" % manage_dhcp_mode + rc = 411 + +sys.exit(rc) -- cgit