summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-11-04 10:15:17 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-11-04 13:00:30 +0000
commitef1b26f67837bc9402b673760238b2fda33acd4e (patch)
tree6f53cec4287ab485e953ab71d82c5d87790a00ce
parent5e0dc63587df78566d95f57ff404639774e86dae (diff)
downloadaports-ef1b26f67837bc9402b673760238b2fda33acd4e.tar.bz2
aports-ef1b26f67837bc9402b673760238b2fda33acd4e.tar.xz
main/nsd: upgrade to 4.0.0
-rw-r--r--main/nsd/APKBUILD36
-rw-r--r--main/nsd/nsd.confd15
-rw-r--r--main/nsd/nsd.initd433
-rw-r--r--main/nsd/nsdc30
4 files changed, 43 insertions, 471 deletions
diff --git a/main/nsd/APKBUILD b/main/nsd/APKBUILD
index 6a8201edc..e7cc42cbd 100644
--- a/main/nsd/APKBUILD
+++ b/main/nsd/APKBUILD
@@ -1,24 +1,21 @@
# Contributor: Matt Smith <mcs@darkregion.net>
# Maintainer: Matt Smith <mcs@darkregion.net>
pkgname=nsd
-pkgver=3.2.16
-pkgrel=2
+pkgver=4.0.0
+pkgrel=0
pkgdesc="NSD is an authoritative only, high performance, simple and open source name server."
url="http://www.nlnetlabs.nl/projects/nsd/"
arch="all"
license="BSD"
depends=
depends_dev=
-makedepends="$depends_dev openssl-dev"
+makedepends="$depends_dev openssl-dev libevent-dev"
install="$pkgname.pre-install $pkgname.post-deinstall"
subpackages="$pkgname-doc"
pkgusers="nsd"
pkggroups="nsd"
source="http://www.nlnetlabs.nl/downloads/$pkgname/$pkgname-$pkgver.tar.gz
- 0010-stop-unlink-pid-error.patch
- nsdc
nsd.initd
- nsd.confd
"
_builddir="$srcdir/$pkgname-$pkgver"
@@ -41,6 +38,8 @@ build() {
--sbindir=/usr/sbin \
--mandir=/usr/share/man \
--with-user=nsd \
+ --with-pidfile=/var/run/nsd/nsd.pid \
+ --with-xfrdir=/var/db/nsd \
|| return 1
make || return 1
}
@@ -49,12 +48,8 @@ package() {
cd "$_builddir"
make DESTDIR="$pkgdir" install || return 1
- install -m755 -D "$srcdir"/nsdc \
- "$pkgdir"/usr/sbin/nsdc || return 1
install -m755 -D "$srcdir"/$pkgname.initd \
"$pkgdir"/etc/init.d/nsd || return 1
- install -m644 -D "$srcdir"/$pkgname.confd \
- "$pkgdir"/etc/conf.d/nsd || return 1
chown nsd "$pkgdir"/var/db/nsd || return 1
}
@@ -71,18 +66,9 @@ doc() {
"$subpkgdir"/usr/share/man || return 1
}
-md5sums="c16a845884851d26c85d5117f11e5f08 nsd-3.2.16.tar.gz
-cc592572846b978a6f52130a8e518ab3 0010-stop-unlink-pid-error.patch
-3aa94004a39319db89a329e9f24fb9da nsdc
-4c0eef07caac9083aeeb9b15602d014d nsd.initd
-37bd648259fdd919c79aaa0168b4423c nsd.confd"
-sha256sums="15a5fd69ea80345eefced83a58b40e8f262a06ac4f7f83606d33033b167d6604 nsd-3.2.16.tar.gz
-729e3897e77ad424b525b93b3df371f239999cf66b7f1271c925dee27721536d 0010-stop-unlink-pid-error.patch
-5295b40d1f55635850837c003993015027f050567d396197875b9287183a05ad nsdc
-e5cc18f8d8a14a6d37f6f536846991c294324cdf4575bf6cf77d7299b1fe0a9a nsd.initd
-1f397b7b98e694787728462a3451433c314a7fc4afbc2d9cfd66dcbae1d793c0 nsd.confd"
-sha512sums="361934717b1975a68c074e0f1fe324259a5939871a6e76f5d7d0535f02a129f0940b16fb544b111c8c8849439c75387e2f50223a2ef3442bac66a2be23bcd529 nsd-3.2.16.tar.gz
-6cf28cf846fd1910b7ed2d143286efec5011486646cab0ea845633c68681ee5e4d2b7462aa6108673966341fc3e5e29c8f2b978981d88c5091855a06af7bdeb0 0010-stop-unlink-pid-error.patch
-c7830033819f3b9e8b4a90ef05f018d5fb7752cc71b3b8ebfd7113302c9a3fc937422fe6a53c0af7608b5a078a001cd104db12383d6531082f51b41cde83daed nsdc
-4fbbd137612ab793ab7b74c38cc557e801fc48a2d564258e015b67f4c7cc85092938bd82e3f45ec09de9996524426086f55fb3a2fd5f830ec580483962275f69 nsd.initd
-356087670fd860f5cc9e2ebc7309fbd9771d2fa3b92b5086cc7b10af459a31a470921d38b30324d152d8de680f0b071ee077093c330dff060a0f1120b4a4d7e5 nsd.confd"
+md5sums="87556b1f8deb3434fd9805d459a96328 nsd-4.0.0.tar.gz
+86c343e8d2976dd120e7436e8d1d1717 nsd.initd"
+sha256sums="62608a409d0f68c9d8d4595031b9de9130ac02efe39733be5dee40d5a90e991c nsd-4.0.0.tar.gz
+947ef0ebeaa6ed97de6cb5bca0be95facffbc8d382366c583de06015d33b8157 nsd.initd"
+sha512sums="75969e0b448a84e16431cbde1a693f4df59e3a036a89ad20cfbda28d31841c31240da3fd69125aae5f19578ef9c9ffc1ddfe8b9bc7877c2df1cef377675fd731 nsd-4.0.0.tar.gz
+b2f2e0d4c6e1f3bcca0f46021ca71d19e924e576c6dd4390b1c15329a00e9249b9c001fed49ebe8aafa9428a671edb7664addf3e382a9bf5bdd05c82f3b5e54a nsd.initd"
diff --git a/main/nsd/nsd.confd b/main/nsd/nsd.confd
deleted file mode 100644
index e37f716ba..000000000
--- a/main/nsd/nsd.confd
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Specify nsd options here.
-#
-
-# configuration file default
-configfile="/etc/nsd/nsd.conf"
-
-# The directory where NSD binaries reside
-sbindir="/usr/sbin"
-
-# how verbose is zonec run. Specify Nothing (empty string), -v or -vv.
-ZONEC_VERBOSE=-v
-
-# how patch is done. Specify 1 (with use of textfiles, default) or 0 (without)
-PATCH_STYLE=1
diff --git a/main/nsd/nsd.initd b/main/nsd/nsd.initd
index f40008049..5115599c6 100644
--- a/main/nsd/nsd.initd
+++ b/main/nsd/nsd.initd
@@ -1,420 +1,51 @@
#!/sbin/runscript
-#
-# nsdc.sh -- a shell script to manage the beast
-#
-# Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
-#
-# See LICENSE for the license.
-#
-# OpenRC conversion by Matt Smith <msmith@alpinelinux.org>
-#
-#
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-dns/nsd/files/nsd.initd,v 1.2 2013/04/03 19:10:39 wschlich Exp $
-name=nsd
-daemon=/usr/sbin/${name}
-initd=/etc/init.d/${name}
+name="NSD"
+description="NSD is an authoritative-only, high performance, open source name server"
+extra_commands="configtest"
-description="NSD, authoritative only high performance name server."
+# these can be overridden in /etc/conf.d/nsd if necessary
+NSD_CONFIG="${NSD_CONFIG:-/etc/nsd/nsd.conf}"
+command="${NSD_BINARY:-/usr/sbin/nsd}"
+NSD_CHECKCONF="${NSD_CHECKCONF:-/usr/sbin/nsd-checkconf}"
-extra_commands="stats reload running patch rebuild update notify do_start do_stop"
-description_reload="Reloads the nsd database file."
-description_running="Prints message and exits nonzero if server is not running."
-description_patch="Merge zone transfer changes back to zone files."
-description_rebuild="Compile database file from zone files."
-description_update="Try to update all slave zones hosted on this server."
-description_notify="Send notify messages to all secondary servers."
-description_do_start="Internal command; use 'start' instead."
-description_do_stop="Internal command; use 'stop' instead."
+command_args="-c ${NSD_CONFIG}"
depend() {
- need net
- after firewall
+ need net
+ use logger
}
-#
-# You sure heard this many times before: NO USER SERVICEABLE PARTS BELOW
-#
-
-# see if user selects a different config file, with -c <filename>
-if test "x$1" = "x-c"; then
- shift
- if [ -e $1 ]; then
- configfile=$1
- shift
- else
- echo "`basename $0`: Config file "$1" does not exist."
- exit 1
- fi
-fi
-
-# locate nsd-checkconf : in sbindir, PATH, nsdc_dir or .
-nsd_checkconf=""
-if [ -e ${sbindir}/nsd-checkconf ]; then
- nsd_checkconf=${sbindir}/nsd-checkconf
-else
- if which nsd-checkconf >/dev/null 2>&1 ; then
- if which nsd-checkconf 2>&1 | grep "^[Nn]o " >/dev/null; then
- nsd_checkconf=""
- else
- nsd_checkconf=`which nsd-checkconf`
- fi
- fi
- if [ -z "${nsd_checkconf}" -a -e `dirname $0`/nsd-checkconf ]; then
- nsd_checkconf=`dirname $0`/nsd-checkconf
- fi
- if [ -z "${nsd_checkconf}" -a -e ./nsd-checkconf ]; then
- nsd_checkconf=./nsd-checkconf
- fi
- if [ -z "${nsd_checkconf}" ]; then
- echo "`basename $0`: Could not find nsd programs" \
- "in $sbindir, in PATH=$PATH, in cwd=`pwd`," \
- "or in dir of nsdc=`dirname $0`"
- exit 1
- fi
-fi
-
-# check the config syntax before using it
-${nsd_checkconf} ${configfile}
-if test $? -ne 0 ; then
- ${initd} describe
- exit 1
-fi
-
-# Read some settings from the config file.
-dbfile=`${nsd_checkconf} -o database ${configfile}`
-pidfile=`${nsd_checkconf} -o pidfile ${configfile}`
-difffile=`${nsd_checkconf} -o difffile ${configfile}`
-zonesdir=`${nsd_checkconf} -o zonesdir ${configfile}`
-lockfile="${dbfile}.lock" # still needed
-sbindir=`dirname ${nsd_checkconf}`
-
-# move to zonesdir (if specified), and make absolute pathnames.
-if test -n "${zonesdir}"; then
- zonesdir=`dirname ${zonesdir}/.`
- if echo "${zonesdir}" | grep "^[^/]" >/dev/null; then
- zonesdir=`pwd`/${zonesdir}
- fi
- if echo "${dbfile}" | grep "^[^/]" >/dev/null; then
- dbfile=${zonesdir}/${dbfile}
- fi
- if echo "${pidfile}" | grep "^[^/]" >/dev/null; then
- pidfile=${zonesdir}/${pidfile}
- fi
- if echo "${lockfile}" | grep "^[^/]" >/dev/null; then
- lockfile=${zonesdir}/${lockfile}
- fi
- if echo "${difffile}" | grep "^[^/]" >/dev/null; then
- difffile=${zonesdir}/${difffile}
- fi
-fi
-
-# for bash: -C or noclobber. For tcsh: noclobber. For bourne: -C.
-noclobber_set="set -C"
-# ugly check for tcsh
-if echo /bin/sh | grep tcsh >/dev/null; then
- noclobber_set="set noclobber"
-fi
-
-#
-# useful routines
-#
-signal() {
- if [ -s ${pidfile} ]
- then
- kill -"$1" `cat ${pidfile}` && return 0
- else
- echo "nsd is not running"
- fi
- return 1
-}
-
-lock_file() {
- (umask 222; ${noclobber_set}; echo "$$" >${lockfile})
-}
-
-lock() {
- lock_file
- if [ $? = 1 ]
- then
- # check if the lockfile has not gone stale
- LPID=`cat ${lockfile}`
- echo database locked by PID: $LPID
- if kill -0 $LPID 2>/dev/null; then
- exit 1
- fi
-
- # locking process does not exist, consider lockfile stale
- echo stale lockfile, removing... && rm -f ${lockfile} && lock_file
- fi
-
- if [ $? = 1 ]
- then
- echo lock failed
- exit 1
- fi
- return 0
-}
-
-unlock() {
- rm -f ${lockfile}
-}
-
-do_start() {
- if test -x ${sbindir}/nsd; then
- ${sbindir}/nsd -c ${configfile}
- test $? = 0 || (echo "nsd startup failed."; exit 1)
- else
- echo "${sbindir}/nsd not an executable file, nsd startup failed."; exit 1
- fi
-}
-
-controlled_sleep() {
- if [ $1 -ge 25 ]; then
- sleep 1
- fi
-}
-
-controlled_stop() {
- pid=$1
- try=1
-
- while [ $try -ne 0 ]; do
- if [ ${try} -gt 50 ]; then
- echo "nsdc stop failed"
- return 1
- else
- if [ $try -eq 1 ]; then
- kill -TERM ${pid}
- else
- kill -TERM ${pid} >/dev/null 2>&1
- fi
-
- # really stopped?
- kill -0 ${pid} >/dev/null 2>&1
- if [ $? -eq 0 ]; then
- controlled_sleep ${try}
- try=`expr ${try} + 1`
- else
- try=0
- fi
- fi
- done
-
- return 0
-}
-
-do_controlled_stop() {
- if [ -s ${pidfile} ]; then
- pid=`cat ${pidfile}`
- controlled_stop ${pid} && return 0
- else
- echo "nsd is not running, starting anyway" && return 0
- fi
- return 1
-}
-
-do_stop() {
- signal "TERM"
-}
-
-do_reload() {
- signal "HUP"
-}
-
-# send_updates zone_name {ip_spec key_spec}
-send_updates() {
- local zonename=$1
- shift 1
- # extract port number (if any)
- port=`${nsd_checkconf} -o port ${configfile}`
- if test -n "${port}"; then
- port="-p ${port}"
- fi
- update_sent="no"
-
- while test $# -gt 0; do
- ip_spec=$1
- key_spec=$2
- shift 2
- # only localhost is allowed.
- # see if zone has 127.0.0.1 or ::1 as allowed.
- if test Z${ip_spec} = "Z127.0.0.1" -o Z${ip_spec} = "Z::1"; then
- secret=""
- if test K${key_spec} != KNOKEY -a K${key_spec} != KBLOCKED; then
- secret=`${nsd_checkconf} -s ${key_spec} ${configfile}`
- algo=`${nsd_checkconf} -a ${key_spec} ${configfile}`
- secret="-y ${key_spec}:${secret}:${algo}"
- fi
- if test K${key_spec} != KBLOCKED; then
- #echo "${sbindir}/nsd-notify -a ${ip_spec} ${port} ${secret} -z ${zonename} ${ip_spec}"
- ${sbindir}/nsd-notify -a ${ip_spec} ${port} ${secret} -z ${zonename} ${ip_spec} && update_sent="yes"
- fi
- fi
- done
- if test ${update_sent} = no; then
- req_xfr=`${nsd_checkconf} -z "${zonename}" -o request-xfr ${configfile}`
- if test -n "${req_xfr}"; then
- # must be a slave zone (has request-xfr).
- echo "`basename $0`: Could not send notify for slave zone ${zonename}: not configured (with allow-notify: 127.0.0.1 or ::1)"
- fi
- fi
-}
-
-# send_notify zone_name ifc_spec {ip_spec key_spec}
-send_notify() {
- local zonename=$1
- # set local interface
- ifc_spec=""
- if test I$2 != INOIFC; then
- ifc_spec="-a $2"
- fi
- shift 2
-
- while test $# -gt 0; do
- ip_spec=$1
- key_spec=$2
- shift 2
- secret=""
-
- if test K${key_spec} != KNOKEY -a K${key_spec} != KBLOCKED; then
- secret=`${nsd_checkconf} -s ${key_spec} ${configfile}`
- algo=`${nsd_checkconf} -a ${key_spec} ${configfile}`
- secret="-y ${key_spec}:${secret}:${algo}"
- fi
- if test K${key_spec} != KBLOCKED; then
- port=""
- ipaddr=${ip_spec}
- if echo ${ip_spec} | grep @ >/dev/null; then
- port="-p "`echo ${ip_spec} | sed -e 's/[^@]*@\([0-9]*\)/\1/'`
- ipaddr=`echo ${ip_spec} | sed -e 's/\([^@]*\)@[0-9]*/\1/'`
- fi
- #echo "${sbindir}/nsd-notify ${ifc_spec} ${port} ${secret} -z ${zonename} ${ipaddr}"
- ${sbindir}/nsd-notify ${ifc_spec} ${port} ${secret} -z ${zonename} ${ipaddr}
- fi
- done
-}
-
-# do_patch {with-textfile}
-do_patch() {
- if test I$1 = I1; then
- lock && mv ${difffile} ${difffile}.$$ && \
- ${sbindir}/nsd-patch -c ${configfile} -x ${difffile}.$$ && \
- rm -f ${difffile}.$$ && unlock && do_rebuild
- result=$?
- else # without textfile
- lock && mv ${difffile} ${difffile}.$$ && \
- ${sbindir}/nsd-patch -c ${configfile} -x ${difffile}.$$ -s -o ${dbfile}.$$ \
- && rm -f ${difffile}.$$ && unlock && \
- mv ${dbfile}.$$ ${dbfile}
- result=$?
- fi
-
- return ${result}
-}
-
-do_rebuild() {
- lock && \
- ${sbindir}/zonec ${ZONEC_VERBOSE} -c ${configfile} -f ${dbfile}.$$ && \
- mv ${dbfile}.$$ ${dbfile}
- result=$?
- unlock
- [ $result != 0 ] && echo "${dbfile} is unmodified"
- rm -f ${dbfile}.$$
- return ${result}
-}
-
-start() {
- ebegin "Starting ${name}"
- if test -s ${pidfile} && kill -"0" `cat ${pidfile}`
- then
- (echo "process `cat ${pidfile}` exists, please use restart"; exit 1)
- else
- start-stop-daemon --start --quiet \
- --pidfile ${pidfile} \
- --exec ${initd} -- do_start
- fi
- eend $?
-}
-
-stop() {
- ebegin "Stopping ${name}"
- start-stop-daemon --stop --quiet \
- --pidfile ${pidfile} \
- --exec ${initd} -- do_stop
+configtest() {
+ ebegin "Checking ${SVCNAME} configuration"
+ checkconfig
eend $?
}
-stats() {
- signal "USR1"
-}
-
-reload() {
- do_reload
-}
-
-running() {
- signal "0"
-}
-
-patch() {
- # patch queue clearen
- if test -s ${difffile}; then
- #${sbindir}/nsd-patch -c ${configfile} -x ${difffile} -l #debug
- #echo ${sbindir}/nsd-patch -c ${configfile} -x ${difffile}
- if do_patch ${PATCH_STYLE}; then
- do_reload
- else
- unlock
- # try to move back the transfer data
- if [ -e ${difffile}.$$ -a ! -e ${difffile} ]; then
- mv ${difffile}.$$ ${difffile}
- fi
- echo "`basename $0`: patch failed."
- exit 1
- fi
- else
- echo "`basename $0`: no patch necessary."
+checkconfig() {
+ if ! test -e "${NSD_CONFIG}"; then
+ eerror "You need to create an appropriate config file."
+ eerror "An example can be found in /etc/nsd/nsd.conf.sample"
+ return 1
+ elif ! "${NSD_CHECKCONF}" "${NSD_CONFIG}"; then
+ eerror "You have errors in your configfile (${NSD_CONFIG})"
+ return $?
fi
+ return 0
}
-rebuild() {
- do_rebuild
+start_pre() {
+ checkconfig || return $?
+ pidfile=$("${NSD_CHECKCONF}" -o pidfile "${NSD_CONFIG}")
+ checkpath --directory --owner nsd:nsd "${pidfile%/*}"
}
-update() {
- # send notifies to localhost for all zones that allow it
- echo "Sending notify to localhost to update secondary zones..."
- if [ -s ${pidfile} ]; then
- zoneslist=`${nsd_checkconf} -o zones ${configfile}`
- for zonename in ${zoneslist}; do
- notify_allow=`${nsd_checkconf} -z "${zonename}" -o allow-notify ${configfile}`
- if test "" != "${notify_allow}"; then
- send_updates ${zonename} ${notify_allow}
- fi
- done
- else
- echo "nsd is not running"
- fi
-}
-notify() {
- # send notifies to all slaves
- echo "Sending notify to slave servers..."
- zoneslist=`${nsd_checkconf} -o zones ${configfile}`
- for zonename in ${zoneslist}; do
- notify=`${nsd_checkconf} -z "${zonename}" -o notify ${configfile}`
- local_ifc=`${nsd_checkconf} -z "${zonename}" -o outgoing-interface ${configfile}`
- if test "" = "${local_ifc}"; then
- local_ifc="NOIFC"
- fi
- if test "" != "${notify}"; then
- for ifc in ${local_ifc}; do
- send_notify ${zonename} ${ifc} ${notify}
- done
- fi
- done
+stop_pre() {
+ checkconfig || return $?
+ pidfile=$("${NSD_CHECKCONF}" -o pidfile "${NSD_CONFIG}")
}
-restart() {
- do_controlled_stop && do_start
-}
diff --git a/main/nsd/nsdc b/main/nsd/nsdc
deleted file mode 100644
index ff4cb5c6b..000000000
--- a/main/nsd/nsdc
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-#
-# nsdc replacement script by Matt Smith <msmith@alpinelinux.org>
-#
-
-usage() {
- echo "Usage: `basename $0` {start|stop|reload|rebuild|restart|"
- echo " running|update|notify|patch}"
- echo "commands:"
- echo " start Start nsd server."
- echo " stop Stop nsd server."
- echo " reload Nsd server reloads database file."
- echo " rebuild Compile database file from zone files."
- echo " restart Stop the nsd server and start it again."
- echo " running Prints message and exit nonzero if server not running."
- echo " update Try to update all slave zones hosted on this server."
- echo " notify Send notify messages to all secondary servers."
- echo " patch Merge zone transfer changes back to zone files."
-}
-
-if [ $# -eq 0 ]; then
- usage
-else
- case "$1" in
- "-h"|"--help")
- usage;;
- *)
- /etc/init.d/nsd $*
- esac
-fi