diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-14 21:23:21 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-14 21:23:57 +0000 |
commit | 0c2a46ee5cde03ff37028a190db9bc68524d5f8c (patch) | |
tree | d56a278a53d8ab3afaf016aca60eba197ef38f12 /main/bind/named.initd | |
parent | e2a0a41ad891af0c727155d1a1e2d69b13480f14 (diff) | |
download | aports-0c2a46ee5cde03ff37028a190db9bc68524d5f8c.tar.bz2 aports-0c2a46ee5cde03ff37028a190db9bc68524d5f8c.tar.xz |
main/bind: cleanup and fix named.initd stop
Diffstat (limited to 'main/bind/named.initd')
-rw-r--r-- | main/bind/named.initd | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/main/bind/named.initd b/main/bind/named.initd new file mode 100644 index 0000000000..c03f35d3a4 --- /dev/null +++ b/main/bind/named.initd @@ -0,0 +1,91 @@ +#!/sbin/runscript + +extra_commands="checkconfig checkzones" +extra_started_commands="reload" + +depend() { + need net + use logger + provide dns +} + +: ${NAMED_CONF:=/etc/bind/named.conf} + +depend() { + need net + after firewall + use logger + provide dns +} + +_get_pidfile() { + [ -n "${PIDFILE}" ] || PIDFILE=$(\ + /usr/sbin/named-checkconf -p ${NAMED_CONF} | grep 'pid-file' | cut -d\" -f2) + [ -z "${PIDFILE}" ] && PIDFILE=/var/run/named/named.pid +} + +checkconfig() { + ebegin "Checking named configuration" + + if [ ! -f "${NAMED_CONF}" ] ; then + eerror "No ${NAMED_CONF} file exists!" + return 1 + fi + + /usr/sbin/named-checkconf ${NAMED_CONF} || { + eerror "named-checkconf failed! Please fix your config first." + return 1 + } + eend 0 + return 0 +} + +checkzones() { + ebegin "Checking named configuration and zones" + /usr/sbin/named-checkconf -z -j ${NAMED_CONF} + eend $? +} + +start() { + local piddir + ebegin "Starting named" + _get_pidfile + piddir="${PIDFILE%/*}" + if [ ! -d "${piddir}" ]; then + checkpath -q -d -o root:named -m 0770 "${piddir}" || { + eend 1 + return 1 + } + fi + + checkconfig || { eend 1; return 1; } + + # create piddir (usually /var/run/named) if necessary, bug 334535 + _get_pidfile + piddir="${PIDFILE%/*}" + if [ ! -d "${piddir}" ]; then + checkpath -q -d -o root:named -m 0770 "${piddir}" || { + eend 1 + return 1 + } + fi + + # In case someone have $CPU set in /etc/conf.d/named + if [ -n "${CPU}" ] && [ "${CPU}" -gt 0 ]; then + CPU="-n ${CPU}" + fi + + start-stop-daemon --start --pidfile ${PIDFILE} \ + --nicelevel ${NICELEVEL:-0} \ + --exec /usr/sbin/named \ + -- -u named ${CPU} ${OPTS} + eend $? +} + +stop() { + ebegin "Stopping named" + _get_pidfile + start-stop-daemon --stop --quiet --pidfile $PIDFILE + eend $? +} + |