summaryrefslogtreecommitdiffstats
path: root/triggers/restart-services.trigger
blob: d586f4667e9b59debed02d3a12b8b28683cbd789 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python

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()
omapi_enabled = settings.omapi_enabled
omapi_port = settings.omapi_port

rc = 0
if manage_dhcp != "0":
    if manage_dhcp_mode == "isc":
        if not omapi_enabled:
            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

if manage_dns != "0":
    rc = os.system("/sbin/service named restart")

sys.exit(rc)