Files
main/server/dhcp/comar/dhcpd.py
T

40 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
from comar.service import *
serviceType = "server"
serviceDesc = _({"en": "DHCP Daemon",
"tr": "DHCP Servisi"})
serviceConf = "dhcpd"
MSG_NM_NOT_RUNNING = _({"en": "NetworkManager service is not running",
"tr": "NetworkManager hizmeti çalışmıyor",
})
PIDFILE = "/run/dhcpd.pid"
TIMEOUT = config.get("TIMEOUT", 10)
@synchronized
def start():
try:
startDependencies("NetworkManager")
# Prevent race condition between NM and dhcpd
if run("/usr/bin/nm-online -q -t %s" % TIMEOUT) != 0:
# NM is not running
fail(MSG_NM_NOT_RUNNING)
except:
pass
startService(command="/usr/sbin/dhcpd",
args="-cf %s %s %s" % (config.get("DHCPD_CONF", "/etc/dhcp/dhcpd.conf"), config.get("DHCPD_ARGS", ""), config.get("INTERFACES", "")),
pidfile=PIDFILE,
donotify=True)
@synchronized
def stop():
stopService(pidfile=PIDFILE,
donotify=True)
def status():
return isServiceRunning(PIDFILE)