aports/main/bind/named.initd

92 lines
1.7 KiB
Bash
Raw Permalink Normal View History

#!/sbin/openrc-run
2009-02-22 22:18:49 +00:00
2012-03-13 10:36:52 +00:00
extra_commands="checkconfig checkzones"
extra_started_commands="reload"
: ${NAMED_CONF:=/etc/bind/named.conf}
2009-02-22 22:18:49 +00:00
depend() {
need net
after firewall entropy
2009-02-22 22:18:49 +00:00
use logger
provide dns
}
2012-03-13 10:36:52 +00:00
_get_pidfile() {
[ -n "${PIDFILE}" ] || PIDFILE=$(\
/usr/bin/named-checkconf -p ${NAMED_CONF} | grep 'pid-file' | cut -d\" -f2)
2012-03-13 10:36:52 +00:00
[ -z "${PIDFILE}" ] && PIDFILE=/var/run/named/named.pid
}
checkconfig() {
ebegin "Checking named configuration"
if [ ! -f "${NAMED_CONF}" ] ; then
eerror "No ${NAMED_CONF} file exists! See the examples in /etc/bind."
2012-03-13 10:36:52 +00:00
return 1
fi
/usr/bin/named-checkconf ${NAMED_CONF} || {
2012-03-13 10:36:52 +00:00
eerror "named-checkconf failed! Please fix your config first."
return 1
}
eend 0
return 0
}
checkzones() {
ebegin "Checking named configuration and zones"
/usr/bin/named-checkconf -z -j ${NAMED_CONF}
2012-03-13 10:36:52 +00:00
eend $?
}
2009-02-22 22:18:49 +00:00
start() {
2012-03-13 10:36:52 +00:00
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}
2009-02-22 22:18:49 +00:00
eend $?
}
stop() {
2012-03-13 10:36:52 +00:00
ebegin "Stopping named"
_get_pidfile
start-stop-daemon --stop --quiet --pidfile $PIDFILE
2009-02-22 22:18:49 +00:00
eend $?
}
2012-03-13 10:36:52 +00:00
reload() {
checkconfig
ebegin "Reloading $name"
rndc reload
eend $?
}