1#!/bin/sh
2#
3# ldap udp-only DNS server
4#
5# chkconfig: - 55 45
6#
7# description: ldapdns is a fast DNS server that uses your LDAP directory\
8# for configuration
9#
10### BEGIN INIT INFO
11# Provides:		named
12# Required-Start:	$network $syslog
13# Required-Stop:	$network $syslog
14# Default-Start:	3 5
15# Default-Stop:		0 1 2 4 6
16# Description:		LDAPDNS is a fast DNS server that uses your LDAP directory for configuration
17### END INIT INTO
18
19# bugfix for some systems that don't supply /sbin for the PATH
20PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
21export PATH
22
23daemon() {
24	prog=$1
25	env UID=$RUN_UID GID=$RUN_GID SUPERVISE=/var/run/$prog.pid $prog
26	RETVAL=$?
27	echo 'ok'
28	return $RETVAL
29}
30killproc() {
31	prog=$1
32	kill `cat /var/run/$prog.pid 2>&1` >/dev/null 2>&1
33	RETVAL=$?
34	echo 'ok'
35	return $RETVAL
36}
37status() {
38	prog=$1
39	if [ -f /var/run/$prog.pid ]; then
40		if kill -0 `cat /var/run/$prog.pid` >/dev/null 2>&1; then
41			echo "$prog is running..."
42			return 0
43		else
44			echo "$prog dead but pidfile exists"
45			return 1
46		fi
47	else
48		echo "$prog is stopped"
49		return 3
50	fi
51}
52
53if [ -f /etc/sysconfig/ldapdns ]; then
54	. /etc/sysconfig/network
55	. /etc/sysconfig/ldapdns
56elif [ -f /etc/ldapdns.conf ]; then
57	. /etc/ldapdns.conf
58	NETWORKING="yes"
59else
60	exit 0
61fi
62
63[ "${NETWORKING}" = "no" ] && exit 0
64[ "${CONFIGURED}" = "no" ] && exit 0
65
66export CACHE HANDLERS THREADS HOSTMASTER LDAP_SUFFIX LDAP_HOST LDAP_HOSTS
67export IP ROOT LDAP_BINDDN LDAP_SASL LDAP_AUTH_NAME RFC1279 DNSRECORD
68export ACCELERATE_CACHE RELATIVE_NAMES LOG
69
70start() {
71	echo -n "Starting ldapdns: "
72	daemon ldapdns
73}
74stop() {
75	echo -n "Shutting down ldapdns: "
76	killproc ldapdns
77}
78restart() {
79	stop
80	start
81}
82reload() {
83	stop
84	start
85}
86
87case "$1" in
88start)		start
89		;;
90stop)		stop
91		;;
92restart)	restart
93		;;
94reload)		reload
95		;;
96force-reload)	reload
97		;;
98status) 	status ldapdns
99		;;
100condrestart)	restart
101		;;
102*)		echo "Usage: $0 {start|stop|restart|status|condrestart}"
103		exit 1
104esac
105
106exit $?
107