diff options
| author | Fabian Affolter <fabian@affolter-engineering.ch> | 2012-03-09 14:14:18 +0000 |
|---|---|---|
| committer | Fabian Affolter <fabian@affolter-engineering.ch> | 2012-03-09 14:14:18 +0000 |
| commit | f43c7bfc8aea4be004ca2907491e18fac1d6ea86 (patch) | |
| tree | 97dff11e37e9a30275c8af0ca423138ee8d18012 /testing/bind/bind.initd | |
| parent | d2ee3e5212c39a5a5bae4078ff3592f8d874147d (diff) | |
| parent | fdc032ee84a0277f1e2b444deb489cda1ad76ae6 (diff) | |
| download | aports-f43c7bfc8aea4be004ca2907491e18fac1d6ea86.tar.bz2 aports-f43c7bfc8aea4be004ca2907491e18fac1d6ea86.tar.xz | |
Merge branch 'master' of git://git.alpinelinux.org/aports
Diffstat (limited to 'testing/bind/bind.initd')
| -rw-r--r-- | testing/bind/bind.initd | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/testing/bind/bind.initd b/testing/bind/bind.initd new file mode 100644 index 000000000..fa9ffb343 --- /dev/null +++ b/testing/bind/bind.initd @@ -0,0 +1,90 @@ +#!/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" + start-stop-daemon --stop --quiet --pidfile $PIDFILE + eend $? +} + |
