handle named_sdb properly; checkconfig() must handle named "-c" option;

make configtest, test, check configcheck synonyms
This commit is contained in:
jvdias 2005-08-17 02:31:35 +00:00
parent 70e5bc5879
commit e9f83dfd42

View File

@ -14,15 +14,19 @@
# Source networking configuration.
[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
RETVAL=0
prog="named"
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 1
[ -r /etc/sysconfig/named ] && . /etc/sysconfig/named
[ -x /usr/sbin/named ] || exit 1
RETVAL=0
named='named'
if [[ "$ENABLE_SDB" = [yY1]* ]] && [ -x /usr/sbin/named_sdb ]; then
named='named_sdb';
fi;
prog=$named
[ -x /usr/sbin/$named ] || exit 1
[ -r ${ROOTDIR}/etc/named.conf ] || exit 1
@ -30,9 +34,9 @@ prog="named"
start() {
# Start daemons.
echo -n $"Starting $prog: "
if [ -n "`/sbin/pidof named`" ]; then
echo -n $"$prog: already running"
echo -n $"Starting $named: "
if [ -n "`/sbin/pidof -o %PPID $named`" ]; then
echo -n $"$named: already running"
failure
echo
return 1
@ -51,6 +55,10 @@ start() {
mount -tproc none ${ROOTDIR}/proc >/dev/null 2>&1
fi
fi
if [[ "${OPTIONS}" = *-c* ]]; then
cf=`echo ${OPTIONS} | sed 's/^.*-c[\ \ ]//;s/[\ \ ].*$//'`;
ckcf_options="$ckcf_options $cf";
fi;
no_write_master_zones=0
if [ -e /etc/selinux/config ]; then
. /etc/selinux/config
@ -86,16 +94,16 @@ start() {
else
RETVAL=$?;
fi
PROG=named
if [[ "$ENABLE_SDB" = [yY1]* ]] && [ -x /usr/sbin/named_sdb ]; then
PROG=named_sdb;
fi;
if [ $conf_ok -eq 1 ]; then
daemon /usr/sbin/$PROG -u named ${OPTIONS};
daemon /usr/sbin/$named -u named ${OPTIONS};
RETVAL=$?;
if [ $RETVAL -eq 0 ]; then
rm -f /var/run/named.pid
rm -f /var/run/named_sdb.pid 2>/dev/null
ln -s $ROOTDIR/var/run/named/named.pid /var/run/named.pid;
if [ "$named" = "named_sdb" ]; then
ln -s $ROOTDIR/var/run/named/named.pid /var/run/named_sdb.pid;
fi;
fi;
else
named_err="`/usr/sbin/named-checkconf $ckcf_options 2>&1`";
@ -115,18 +123,20 @@ start() {
}
stop() {
# Stop daemons.
echo -n $"Stopping $prog: "
echo -n $"Stopping $named: "
/usr/sbin/rndc stop >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/named
rm -f /var/run/named.pid
elif pidof named >/dev/null; then
killproc named -TERM >/dev/null 2>&1
rm -f /var/run/named_sdb.pid 2>/dev/null
elif /sbin/pidof -o %PPID $named >/dev/null; then
killproc $named -TERM >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/named
rm -f /var/run/named.pid
rm -f /var/run/named_sdb.pid 2>/dev/null
fi;
fi;
if [ $RETVAL -eq 0 ]; then
@ -137,7 +147,6 @@ stop() {
echo
return $RETVAL
}
rhstatus() {
/usr/sbin/rndc status
return $?
@ -149,14 +158,14 @@ restart() {
start
}
reload() {
echo -n $"Reloading $prog: "
p=`/sbin/pidof -o %PPID named`
echo -n $"Reloading $named: "
p=`/sbin/pidof -o %PPID $named`
RETVAL=$?
if [ "$RETVAL" -eq 0 ]; then
/usr/sbin/rndc reload >/dev/null 2>&1 || /bin/kill -HUP $p;
RETVAL=$?
fi
[ "$RETVAL" -eq 0 ] && success $"$prog reload" || failure $"$prog reload"
[ "$RETVAL" -eq 0 ] && success $"$named reload" || failure $"$named reload"
echo
return $?
}
@ -172,6 +181,10 @@ checkconfig() {
OPTIONS="${OPTIONS} -t ${ROOTDIR}"
ckcf_options="$ckcf_options -t ${ROOTDIR}";
fi;
if [[ "${OPTIONS}" = *-c* ]]; then
cf=`echo ${OPTIONS} | sed 's/^.*-c[\ \ ]//;s/[\ \ ].*$//'`;
ckcf_options="$ckcf_options $cf";
fi;
if [ -x /usr/sbin/named-checkconf ] && [ -x /usr/sbin/named-checkzone ] && /usr/sbin/named-checkconf $ckcf_options ; then
return 0;
else
@ -202,7 +215,7 @@ case "$1" in
probe)
probe
;;
checkconfig)
checkconfig|configtest|check|test)
checkconfig
;;
*)