2 # Copyright 1999-2012 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
6 extra_commands="rebuild"
7 extra_started_commands="reload"
8 description="NSD is an authoritative only, high performance, open source name server"
9 description_reload="Rebuild zone database and reload it"
11 config_file=${config_file:-/etc/nsd/nsd.conf}
12 my_nsdc="/usr/sbin/nsdc"
13 my_nsd_checkconf="/usr/sbin/nsd-checkconf"
22 if ! test -e "${config_file}"; then
23 eerror "You need to create an appropriate config file."
24 eerror "An example can be found in /etc/nsd/nsd.conf.sample"
28 if ! ${my_nsd_checkconf} "${config_file}"; then
29 eerror "You have errors in your configfile (${config_file})"
36 local database=$(${my_nsd_checkconf} -o database ${config_file})
37 if ! test -f $database; then
38 eerror "You have no database file in ${database}, will try to rebuild"
45 local difffile=$(${my_nsd_checkconf} -o difffile ${config_file})
46 if test -s ${difffile}; then
47 ebegin "Patching NSD zone files"
48 ${my_nsdc} patch > /dev/null
54 ebegin "Rebuilding NSD zone database"
55 if ! ${my_nsdc} rebuild > /dev/null; then
56 eerror "There was an error rebuilding the database. Please review your zone files."
64 _checkconf || return 1
65 _checkdb || rebuild || return 1
79 _checkconf || return 1
81 ebegin "Reloading NSD zone database"