|
cvsdist |
2f7f4b |
#!/bin/bash
|
|
cvsdist |
2f7f4b |
#
|
|
cvsdist |
2f7f4b |
# named This shell script takes care of starting and stopping
|
|
cvsdist |
2f7f4b |
# named (BIND DNS server).
|
|
cvsdist |
2f7f4b |
#
|
|
cvsdist |
2f7f4b |
# chkconfig: - 55 45
|
|
cvsdist |
2f7f4b |
# description: named (BIND) is a Domain Name Server (DNS) \
|
|
cvsdist |
2f7f4b |
# that is used to resolve host names to IP addresses.
|
|
cvsdist |
2f7f4b |
# probe: true
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
2f7f4b |
# Source function library.
|
|
cvsdist |
2f7f4b |
. /etc/rc.d/init.d/functions
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
2f7f4b |
# Source networking configuration.
|
|
cvsdist |
4f506d |
[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
78e1f2 |
RETVAL=0
|
|
cvsdist |
78e1f2 |
prog="named"
|
|
cvsdist |
78e1f2 |
|
|
cvsdist |
2f7f4b |
# Check that networking is up.
|
|
jvdias |
e51c8f |
[ "${NETWORKING}" = "no" ] && exit 1
|
|
cvsdist |
aed712 |
|
|
cvsdist |
78e1f2 |
[ -r /etc/sysconfig/named ] && . /etc/sysconfig/named
|
|
cvsdist |
2f7f4b |
|
|
jvdias |
e51c8f |
[ -x /usr/sbin/named ] || exit 1
|
|
cvsdist |
2f7f4b |
|
|
jvdias |
e51c8f |
[ -r ${ROOTDIR}/etc/named.conf ] || exit 1
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
2f7f4b |
start() {
|
|
cvsdist |
2f7f4b |
# Start daemons.
|
|
cvsdist |
0a52a5 |
if [ -n "`/sbin/pidof named`" ]; then
|
|
cvsdist |
0a52a5 |
echo -n $"$prog: already running"
|
|
cvsdist |
0a52a5 |
return 1
|
|
cvsdist |
0a52a5 |
fi
|
|
cvsdist |
aed712 |
echo -n $"Starting $prog: "
|
|
cvsdist |
1d13f1 |
ckcf_options='';
|
|
cvsdist |
aed712 |
if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then
|
|
cvsdist |
aed712 |
OPTIONS="${OPTIONS} -t ${ROOTDIR}"
|
|
cvsdist |
1d13f1 |
ckcf_options="-t ${ROOTDIR}";
|
|
jvdias |
d3f558 |
if [ -s /etc/localtime ]; then
|
|
jvdias |
d3f558 |
cp -fp /etc/localtime ${ROOTDIR}/etc/localtime
|
|
jvdias |
d3f558 |
fi;
|
|
cvsdist |
aed712 |
fi
|
|
jvdias |
18d1e1 |
no_write_master_zones=0
|
|
jvdias |
23b1ff |
if [ -e /etc/selinux/config ]; then
|
|
jvdias |
23b1ff |
. /etc/selinux/config
|
|
jvdias |
18d1e1 |
if [ "$SELINUX" != 'disabled' ] && [ "$SELINUXTYPE" != "" ] && [ -d /etc/selinux/${SELINUXTYPE} ] && [ -e /etc/selinux/${SELINUXTYPE}/booleans ]; then
|
|
jvdias |
23b1ff |
. /etc/selinux/${SELINUXTYPE}/booleans
|
|
jvdias |
2dbdf5 |
if echo "$named_write_master_zones" | /bin/egrep -q '^[0-9]+$'; then
|
|
jvdias |
2dbdf5 |
if [ "$named_write_master_zones" -eq 1 ] ; then
|
|
jvdias |
2dbdf5 |
/bin/chown -f --from=root:named named:named $ROOTDIR/var/named
|
|
jvdias |
2dbdf5 |
elif [ "$named_write_master_zones" -eq 0 ] ; then
|
|
jvdias |
2dbdf5 |
/bin/chown -f --from=named:named root:named $ROOTDIR/var/named
|
|
jvdias |
2dbdf5 |
fi;
|
|
jvdias |
2dbdf5 |
fi;
|
|
jvdias |
18d1e1 |
else
|
|
jvdias |
18d1e1 |
no_write_master_zones=1
|
|
jvdias |
23b1ff |
fi;
|
|
jvdias |
18d1e1 |
else
|
|
jvdias |
18d1e1 |
no_write_master_zones=1
|
|
jvdias |
23b1ff |
fi;
|
|
jvdias |
18d1e1 |
if [ "$no_write_master_zones" -eq 1 ]; then
|
|
jvdias |
18d1e1 |
if [[ "$ENABLE_ZONE_WRITE" = [yY1]* ]]; then
|
|
jvdias |
18d1e1 |
/bin/chown -f --from=root:named named:named $ROOTDIR/var/named
|
|
jvdias |
18d1e1 |
elif [[ "$ENABLE_ZONE_WRITE" = [nN0]* ]]; then
|
|
jvdias |
18d1e1 |
/bin/chown -f --from=named:named root:named $ROOTDIR/var/named
|
|
jvdias |
18d1e1 |
fi;
|
|
jvdias |
18d1e1 |
fi
|
|
cvsdist |
49d83b |
conf_ok=0;
|
|
cvsdist |
1d13f1 |
if [ -x /usr/sbin/named-checkconf ] && /usr/sbin/named-checkconf $ckcf_options; then
|
|
cvsdist |
49d83b |
conf_ok=1;
|
|
cvsdist |
49d83b |
else
|
|
cvsdist |
49d83b |
RETVAL=$?;
|
|
cvsdist |
49d83b |
fi
|
|
jvdias |
18d1e1 |
PROG=named
|
|
jvdias |
18d1e1 |
if [[ "$ENABLE_SDB" = [yY1]* ]] && [ -x /usr/sbin/named_sdb ]; then
|
|
jvdias |
18d1e1 |
PROG=named_sdb;
|
|
jvdias |
18d1e1 |
fi;
|
|
cvsdist |
49d83b |
if [ $conf_ok -eq 1 ]; then
|
|
jvdias |
18d1e1 |
daemon /usr/sbin/$PROG -u named ${OPTIONS};
|
|
cvsdist |
49d83b |
RETVAL=$?;
|
|
cvsdist |
49d83b |
else
|
|
cvsdist |
668aac |
named_err=`/usr/sbin/named -g 2>&1 | sed s/\n/\\n/g`;
|
|
cvsdist |
668aac |
if [ `tty` != "/dev/console" ]; then
|
|
cvsdist |
668aac |
echo -e "\n$named_err";
|
|
cvsdist |
668aac |
echo -n "Error in configuration file /etc/named.conf : ";
|
|
cvsdist |
668aac |
fi;
|
|
cvsdist |
668aac |
failure $"Error in configuration file /etc/named.conf : $named_err";
|
|
cvsdist |
49d83b |
echo
|
|
cvsdist |
49d83b |
return $RETVAL;
|
|
cvsdist |
49d83b |
fi;
|
|
cvsdist |
78e1f2 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/named
|
|
cvsdist |
4f506d |
echo
|
|
cvsdist |
2f7f4b |
return $RETVAL
|
|
cvsdist |
2f7f4b |
}
|
|
cvsdist |
2f7f4b |
stop() {
|
|
cvsdist |
2f7f4b |
# Stop daemons.
|
|
cvsdist |
aed712 |
echo -n $"Stopping $prog: "
|
|
cvsdist |
d69ee3 |
/usr/sbin/rndc stop >/dev/null 2>&1
|
|
cvsdist |
2f7f4b |
RETVAL=$?
|
|
cvsdist |
aa0a29 |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named || {
|
|
jvdias |
e51c8f |
# killproc named
|
|
jvdias |
e51c8f |
# Never do this! Can cause corrupt zone files!
|
|
jvdias |
e51c8f |
/usr/sbin/rndc stop >/dev/null 2>&1
|
|
cvsdist |
aa0a29 |
RETVAL=$?
|
|
cvsdist |
aa0a29 |
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named
|
|
cvsdist |
4f506d |
echo
|
|
cvsdist |
4f506d |
return $RETVAL
|
|
cvsdist |
aa0a29 |
}
|
|
cvsdist |
4f506d |
success
|
|
cvsdist |
2f7f4b |
echo
|
|
cvsdist |
2f7f4b |
return $RETVAL
|
|
cvsdist |
2f7f4b |
}
|
|
cvsdist |
2f7f4b |
rhstatus() {
|
|
cvsdist |
366442 |
/usr/sbin/rndc status
|
|
cvsdist |
366442 |
return $?
|
|
cvsdist |
2f7f4b |
}
|
|
cvsdist |
2f7f4b |
restart() {
|
|
cvsdist |
2f7f4b |
stop
|
|
cvsdist |
78e1f2 |
# wait a couple of seconds for the named to finish closing down
|
|
cvsdist |
78e1f2 |
sleep 2
|
|
cvsdist |
2f7f4b |
start
|
|
cvsdist |
2f7f4b |
}
|
|
cvsdist |
2f7f4b |
reload() {
|
|
cvsdist |
78e1f2 |
echo -n $"Reloading $prog: "
|
|
cvsdist |
d69ee3 |
p=`/sbin/pidof -o %PPID named`
|
|
cvsdist |
d69ee3 |
RETVAL=$?
|
|
cvsdist |
d69ee3 |
if [ "$RETVAL" -eq 0 ]; then
|
|
cvsdist |
d69ee3 |
/usr/sbin/rndc reload >/dev/null 2>&1 || /usr/bin/kill -HUP $p;
|
|
cvsdist |
d69ee3 |
RETVAL=$?
|
|
cvsdist |
d69ee3 |
fi
|
|
cvsdist |
d69ee3 |
[ "$RETVAL" -eq 0 ] && success $"$prog reload" || failure $"$prog reload"
|
|
cvsdist |
78e1f2 |
echo
|
|
cvsdist |
2f7f4b |
return $?
|
|
cvsdist |
2f7f4b |
}
|
|
cvsdist |
2f7f4b |
probe() {
|
|
cvsdist |
2f7f4b |
# named knows how to reload intelligently; we don't want linuxconf
|
|
cvsdist |
2f7f4b |
# to offer to restart every time
|
|
cvsdist |
aed712 |
/usr/sbin/rndc reload >/dev/null 2>&1 || echo start
|
|
cvsdist |
2f7f4b |
return $?
|
|
cvsdist |
2f7f4b |
}
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
2f7f4b |
# See how we were called.
|
|
cvsdist |
2f7f4b |
case "$1" in
|
|
cvsdist |
2f7f4b |
start)
|
|
cvsdist |
2f7f4b |
start
|
|
cvsdist |
2f7f4b |
;;
|
|
cvsdist |
2f7f4b |
stop)
|
|
cvsdist |
2f7f4b |
stop
|
|
cvsdist |
2f7f4b |
;;
|
|
cvsdist |
2f7f4b |
status)
|
|
cvsdist |
2f7f4b |
rhstatus
|
|
cvsdist |
2f7f4b |
;;
|
|
cvsdist |
2f7f4b |
restart)
|
|
cvsdist |
2f7f4b |
restart
|
|
cvsdist |
2f7f4b |
;;
|
|
cvsdist |
2f7f4b |
condrestart)
|
|
cvsdist |
31bdca |
if [ -e /var/lock/subsys/named ]; then restart; fi
|
|
cvsdist |
2f7f4b |
;;
|
|
cvsdist |
2f7f4b |
reload)
|
|
cvsdist |
2f7f4b |
reload
|
|
cvsdist |
2f7f4b |
;;
|
|
cvsdist |
2f7f4b |
probe)
|
|
cvsdist |
2f7f4b |
probe
|
|
cvsdist |
2f7f4b |
;;
|
|
cvsdist |
2f7f4b |
*)
|
|
cvsdist |
aed712 |
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|probe}"
|
|
cvsdist |
2f7f4b |
exit 1
|
|
cvsdist |
2f7f4b |
esac
|
|
cvsdist |
2f7f4b |
|
|
cvsdist |
2f7f4b |
exit $?
|
|
cvsdist |
2f7f4b |
|