summaryrefslogtreecommitdiff
path: root/user/bind/named.initd
diff options
context:
space:
mode:
authorDan Theisen <djt@hxx.in>2018-07-06 00:13:54 -0700
committerDan Theisen <djt@hxx.in>2018-07-06 02:34:42 -0700
commitdf1a5e501763e44127dc660b01fd036de5b94112 (patch)
tree1a52ba11a2f6872c17f25dea1fc6265538eb0f43 /user/bind/named.initd
parent5b7b4d541766dcaa27db11fc82a5114790828deb (diff)
downloadpackages-df1a5e501763e44127dc660b01fd036de5b94112.tar.gz
packages-df1a5e501763e44127dc660b01fd036de5b94112.tar.bz2
packages-df1a5e501763e44127dc660b01fd036de5b94112.tar.xz
packages-df1a5e501763e44127dc660b01fd036de5b94112.zip
user/bind: import, take, clean up, update root zone
Diffstat (limited to 'user/bind/named.initd')
-rw-r--r--user/bind/named.initd84
1 files changed, 84 insertions, 0 deletions
diff --git a/user/bind/named.initd b/user/bind/named.initd
new file mode 100644
index 000000000..a088aa4d3
--- /dev/null
+++ b/user/bind/named.initd
@@ -0,0 +1,84 @@
+#!/sbin/openrc-run
+
+extra_commands="checkconfig checkzones"
+extra_started_commands="reload"
+: ${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! See the examples in /etc/bind."
+ 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 $?
+}
+