summaryrefslogtreecommitdiffstats
path: root/triggers
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-10-19 16:44:06 -0400
committerMichael DeHaan <mdehaan@redhat.com>2007-10-19 16:44:06 -0400
commit1b1222ec7f95a773fcab39bf1ebe68da198919be (patch)
treeb180dc9a976886f143d0743cd725d3ec5bd3c707 /triggers
parentd09c20fc07efb87cffcbac467f189e312eb67e9e (diff)
downloadthird_party-cobbler-1b1222ec7f95a773fcab39bf1ebe68da198919be.tar.gz
third_party-cobbler-1b1222ec7f95a773fcab39bf1ebe68da198919be.tar.xz
third_party-cobbler-1b1222ec7f95a773fcab39bf1ebe68da198919be.zip
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.
Diffstat (limited to 'triggers')
-rw-r--r--triggers/restart-services.trigger21
1 files changed, 21 insertions, 0 deletions
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)