[BIND] Edit "/etc/init.d/named"

IPaddress

Verified User
Joined
Feb 21, 2004
Messages
92
Hi!
Im running Directadmin 1.33.6 under CentOS 5, with BIND 9.3.4-P1.
All its working fine. However Directadmin cant start/stop/restart the named service, cause the file /etc/init.d/named its not starting the named service with the user named (so it fails to start).

If i want to start it manually i've to wirte
# named -u named
And all starts perfectly.
How can i edit the /etc/init.d/named to make it starts/stop/restart the service with the user "named"?

Thanks in advance.

Bye!
 
edit it with your favorite editor and change the start line to that.
 
Well, that sounds easy but its not :(


# cat /etc/init.d/named
------------------------------------------------------------------
#!/bin/bash
#
# named This shell script takes care of starting and stopping
# named (BIND DNS server).
#
# chkconfig: - 13 87
# description: named (BIND) is a Domain Name Server (DNS) \
# that is used to resolve host names to IP addresses.
# probe: true

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network

[ -r /etc/sysconfig/named ] && . /etc/sysconfig/named

export KRB5_KTNAME=${KEYTAB_FILE:-/etc/named.keytab}

# Don't kill named during clean-up
NAMED_SHUTDOWN_TIMEOUT=${NAMED_SHUTDOWN_TIMEOUT:-100}

if [ -n "$ROOTDIR" ]; then
ROOTDIR=`echo $ROOTDIR | sed 's#//*#/#g;s#/$##'`;
rdl=`/usr/bin/readlink $ROOTDIR`;
if [ -n "$rdl" ]; then
ROOTDIR="$rdl";
fi;
fi

RETVAL=0
named='named'
if [[ "$ENABLE_SDB" = [yY1]* ]] && [ -x /usr/sbin/named_sdb ]; then
named='named_sdb';
fi;
prog=$named

nmdcOption()
{ let i=0;
for a in $*;
do ((++i));
if [ $a = -c ]; then
((++i));
eval 'echo $'$i;
elif [[ $a = -c* ]]; then
echo ${a#-c};
fi;
done;
}

named_c_option=`nmdcOption $OPTIONS`;
named_conf=${named_c_option:-/etc/named.conf};

dbusEnabled=0;
for a in $OPTIONS; do
if [ $a = "-D" ]; then
dbusEnabled=1;
fi;
done

if [ $dbusEnabled -eq 0 ] && [ -z "$DISABLE_NAMED_DBUS" ] ; then
NetworkManagerEnabled=0
for l in 0 1 2 3 4 5 6; do
if /sbin/chkconfig --level=$l NetworkManager >/dev/null 2>&1; then
NetworkManagerEnabled=1;
fi;
done
if [ $NetworkManagerEnabled -eq 1 ]; then
OPTIONS="$OPTIONS -D";
fi;
dbusEnabled=1;
fi

start() {
[ -x /usr/sbin/$named ] || exit 5

if [ ! -r ${ROOTDIR}${named_conf} ] ; then
if [ -z "$named_c_option" ] && [ -r ${ROOTDIR}/etc/named.caching-nameserver.conf ]; then
named_conf='/etc/named.caching-nameserver.conf';
OPTIONS="$OPTIONS -c ${named_conf}";
else
echo Locating $ROOTDIR/${named_conf} failed:
failure
echo;
exit 6;
fi;
fi;

# Start daemons.
echo -n $"Starting $named: "
if [ -n "`/sbin/pidof -o %PPID $named`" ]; then
echo -n $"$named: already running"
failure
echo
return 1
fi
ckcf_options='-z'; # enable named-checkzone for each zone (9.3.1+) !
if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then
OPTIONS="${OPTIONS} -t ${ROOTDIR}"
ckcf_options="$ckcf_options -t ${ROOTDIR}";
if [ -s /etc/localtime ]; then
cp -fp /etc/localtime ${ROOTDIR}/etc/localtime
fi;
if [ ! -d ${ROOTDIR}/proc ]; then
mkdir -p ${ROOTDIR}/proc
fi
if ! egrep -q '^/proc[[:space:]]+'${ROOTDIR}'/proc' /proc/mounts; then
mount --bind -n /proc ${ROOTDIR}/proc >/dev/null 2>&1
fi
if [ $dbusEnabled -eq 1 ]; then
if ! egrep -q '^/[^[:space:]]+[[:space:]]+'${ROOTDIR}'/var/run/dbus' /proc/mounts; then
mkdir -p ${ROOTDIR}/var/run/dbus
if [ ! -d /var/run/dbus ] ; then
mkdir -p /var/run/dbus ;
fi;
mount --bind -n /var/run/dbus ${ROOTDIR}/var/run/dbus > /dev/null 2>&1;
fi;
fi;
fi
no_write_master_zones=0
if [ -e /etc/selinux/config ]; then
. /etc/selinux/config
if [[ ( "$SELINUX" != 'disabled') && ("$SELINUXTYPE" != "") && (-d /etc/selinux/${SELINUXTYPE}) && (-e /etc/selinux/${SELINUXTYPE}/booleans || (-e /etc/selinux/${SELINUXTYPE}/booleans.local)) ]]; then
if [ -e /etc/selinux/${SELINUXTYPE}/booleans.local ]; then
. /etc/selinux/${SELINUXTYPE}/booleans.local;
else
. /etc/selinux/${SELINUXTYPE}/booleans;
fi;
if echo "$named_write_master_zones" | /bin/egrep -q '^[0-9]+$'; then
if [ "$named_write_master_zones" -eq 1 ] ; then
/bin/chown -f --from=root:named named:named $ROOTDIR/var/named
elif [ "$named_write_master_zones" -eq 0 ] ; then
/bin/chown -f --from=named:named root:named $ROOTDIR/var/named
fi;
fi;
else
no_write_master_zones=1
fi;
else
no_write_master_zones=1
fi;
if [ "$no_write_master_zones" -eq 1 ]; then
if [[ "$ENABLE_ZONE_WRITE" = [yY1]* ]]; then
/bin/chown -f --from=root:named named:named $ROOTDIR/var/named
elif [[ "$ENABLE_ZONE_WRITE" = [nN0]* ]]; then
/bin/chown -f --from=named:named root:named $ROOTDIR/var/named
fi;
fi
conf_ok=0;
if [ -x /usr/sbin/named-checkconf ] && [ -x /usr/sbin/named-checkzone ] && /usr/sbin/named-checkconf $ckcf_options ${named_conf} >/dev/null 2>&1; then
conf_ok=1;
else
RETVAL=$?;
fi
if [ $conf_ok -eq 1 ]; then
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;
if [ -n "`/sbin/pidof -o %PPID $named`" ]; then
# Verify that named actually started (JM 2006-10-04)
if [ ! -e $ROOTDIR/var/run/named/named.pid ]; then
# If there is not a file containing the PID of the now running named daemon then create it (JM 2006-10-04)
echo `/sbin/pidof -o %PPID $named` > $ROOTDIR/var/run/named/named.pid;
if [ "$named" = "named_sdb" ]; then
echo `/sbin/pidof -o %PPID $named` > $ROOTDIR/var/run/named/named_sdb.pid;
fi;
fi;
fi;
else
named_err="`/usr/sbin/named-checkconf $ckcf_options $named_conf 2>&1`";
echo
echo $"Error in named configuration"':';
echo "$named_err";
failure
echo
if [ -x /usr/bin/logger ]; then
echo "$named_err" | /usr/bin/logger -pdaemon.error -tnamed
fi;
return 7;
fi;
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/named
echo
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Stopping $named: "
/usr/sbin/rndc stop >/dev/null 2>&1
RETVAL=$?
[ "$RETVAL" -eq 0 ] || killproc "$named" -TERM >/dev/null 2>&1

timeout=0
RETVAL=0
while /sbin/pidof -o %PPID "$named" >/dev/null; do
if [ $timeout -ge $NAMED_SHUTDOWN_TIMEOUT ]; then
RETVAL=1
break
else
sleep 2 && echo -n "."
timeout=$((timeout+2))
fi;
done
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;
if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then
if egrep -q '^/proc[[:space:]]+'${ROOTDIR}'/proc' /proc/mounts; then
umount ${ROOTDIR}/proc >/dev/null 2>&1
fi
if [ $dbusEnabled -eq 1 ]; then
if egrep -q '^/[^[:space:]]+[[:space:]]+'${ROOTDIR}'/var/run/dbus' /proc/mounts; then
umount ${ROOTDIR}/var/run/dbus > /dev/null 2>&1
fi;
fi;
fi;
if [ $RETVAL -eq 0 ]; then
success
else
failure
fi;
echo
return $RETVAL
}
rhstatus() {
/usr/sbin/rndc status
status /usr/sbin/$named
return $?
}
restart() {
stop
# wait a couple of seconds for the named to finish closing down
sleep 2
start
}
reload() {
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 $"$named reload" || failure $"$named reload"
echo
return $RETVAL
}
probe() {
# named knows how to reload intelligently; we don't want linuxconf
# to offer to restart every time
/usr/sbin/rndc reload >/dev/null 2>&1 || echo start
return $?
}
checkconfig() {
ckcf_options='-z'; # enable named-checkzone for each zone (9.3.1+) !
if [ -n "${ROOTDIR}" -a "x${ROOTDIR}" != "x/" ]; then
OPTIONS="${OPTIONS} -t ${ROOTDIR}"
ckcf_options="$ckcf_options -t ${ROOTDIR}";
fi;
if [ -x /usr/sbin/named-checkconf ] && [ -x /usr/sbin/named-checkzone ] && /usr/sbin/named-checkconf $ckcf_options ${named_conf} | cat ; then
return 0;
else
return 1;
fi
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
rhstatus
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/subsys/named ] && restart;
;;
reload)
reload
;;
probe)
probe
;;
checkconfig|configtest|check|test)
checkconfig
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|configtest|probe}"
exit 2
esac

exit $?
------------------------------------------------------------------
/etc/init.d/named start: fails
named -u named: works
Restarting named with Directadmin service monitor: fails

I dont know what i have to modify. Can someone help me with this?
Thanks in advance!

Bye.
 
if your running named under user named you can just change this line:

Code:
named='named'

to

Code:
named='named -u named'
 
There already is "-u named" in there, no need to specify it twice. The error is elsewhere.
Use "bash +x /etc/init.d/named start".
 
There already is "-u named" in there, no need to specify it twice. The error is elsewhere.
Use "bash +x /etc/init.d/named start".

---------------------------------------------------------------
# bash -x /etc/init.d/named stop

+ . /etc/rc.d/init.d/functions
++ TEXTDOMAIN=initscripts
++ umask 022
++ PATH=/sbin:/usr/sbin:/bin:/usr/bin
++ export PATH
++ '[' -z '' ']'
++ COLUMNS=80
++ '[' -z '' ']'
+++ /sbin/consoletype
++ CONSOLETYPE=pty
++ '[' -f /etc/sysconfig/i18n -a -z '' ']'
++ . /etc/profile.d/lang.sh
+++ sourced=0
+++ for langfile in /etc/sysconfig/i18n '$HOME/.i18n'
+++ '[' -f /etc/sysconfig/i18n ']'
+++ . /etc/sysconfig/i18n
++++ LANG=en_US.UTF-8
++++ SYSFONT=latarcyrheb-sun16
+++ sourced=1
+++ for langfile in /etc/sysconfig/i18n '$HOME/.i18n'
+++ '[' -f /root/.i18n ']'
+++ '[' -n '' ']'
+++ '[' 1 = 1 ']'
+++ '[' -n en_US.UTF-8 ']'
+++ export LANG
+++ '[' -n '' ']'
+++ unset LC_ADDRESS
+++ '[' -n '' ']'
+++ unset LC_CTYPE
+++ '[' -n '' ']'
+++ unset LC_COLLATE
+++ '[' -n '' ']'
+++ unset LC_IDENTIFICATION
+++ '[' -n '' ']'
+++ unset LC_MEASUREMENT
+++ '[' -n '' ']'
+++ unset LC_MESSAGES
+++ '[' -n '' ']'
+++ unset LC_MONETARY
+++ '[' -n '' ']'
+++ unset LC_NAME
+++ '[' -n '' ']'
+++ unset LC_NUMERIC
+++ '[' -n '' ']'
+++ unset LC_PAPER
+++ '[' -n '' ']'
+++ unset LC_TELEPHONE
+++ '[' -n '' ']'
+++ unset LC_TIME
+++ '[' -n '' ']'
+++ unset LC_ALL
+++ '[' -n '' ']'
+++ unset LANGUAGE
+++ '[' -n '' ']'
+++ unset LINGUAS
+++ '[' -n '' ']'
+++ unset _XKB_CHARSET
++++ /sbin/consoletype
+++ consoletype=pty
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n en_US.UTF-8 ']'
+++ case $LANG in
+++ '[' xterm = linux ']'
+++ unset SYSFONTACM SYSFONT
+++ unset sourced
+++ unset langfile
++ '[' -z '' ']'
++ '[' -f /etc/sysconfig/init ']'
++ . /etc/sysconfig/init
+++ BOOTUP=color
+++ GRAPHICAL=yes
+++ RES_COL=60
+++ MOVE_TO_COL='echo -en \033[60G'
+++ SETCOLOR_SUCCESS='echo -en \033[0;32m'
+++ SETCOLOR_FAILURE='echo -en \033[0;31m'
+++ SETCOLOR_WARNING='echo -en \033[0;33m'
+++ SETCOLOR_NORMAL='echo -en \033[0;39m'
+++ LOGLEVEL=3
+++ PROMPT=yes
+++ AUTOSWAP=no
++ '[' pty = serial ']'
++ '[' color '!=' verbose ']'
++ INITLOG_ARGS=-q
++ __sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
+ '[' -r /etc/sysconfig/network ']'
+ . /etc/sysconfig/network
++ NETWORKING=yes
++ NETWORKING_IPV6=no
++ HOSTNAME=lnx2.ipaddress.com.ar
+ '[' -r /etc/sysconfig/named ']'
+ . /etc/sysconfig/named
+ export KRB5_KTNAME=/etc/named.keytab
+ KRB5_KTNAME=/etc/named.keytab
+ NAMED_SHUTDOWN_TIMEOUT=100
+ '[' -n '' ']'
+ RETVAL=0
+ named=named
+ [[ '' = [yY1]* ]]
+ prog=named
++ nmdcOption
++ let i=0
+ named_c_option=
+ named_conf=/etc/named.conf
+ dbusEnabled=0
+ '[' 0 -eq 0 ']'
+ '[' -z '' ']'
+ NetworkManagerEnabled=0
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=0 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=1 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=2 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=3 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=4 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=5 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=6 NetworkManager
+ '[' 0 -eq 1 ']'
+ dbusEnabled=1
+ case "$1" in
+ stop
+ echo -n 'Stopping named: '
Stopping named: + /usr/sbin/rndc stop
+ RETVAL=0
+ '[' 0 -eq 0 ']'
+ timeout=0
+ RETVAL=0
+ /sbin/pidof -o %PPID named
+ '[' 0 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=2
+ /sbin/pidof -o %PPID named
+ '[' 2 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=4
+ /sbin/pidof -o %PPID named
+ '[' 4 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=6
+ /sbin/pidof -o %PPID named
+ '[' 6 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=8
+ /sbin/pidof -o %PPID named
+ '[' 8 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=10
+ /sbin/pidof -o %PPID named
+ '[' 10 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=12
+ /sbin/pidof -o %PPID named
+ '[' 12 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=14
+ /sbin/pidof -o %PPID named
+ '[' 14 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=16
+ /sbin/pidof -o %PPID named
+ '[' 16 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=18
+ /sbin/pidof -o %PPID named
+ '[' 18 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=20
+ /sbin/pidof -o %PPID named
+ '[' 20 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=22
+ /sbin/pidof -o %PPID named
+ '[' 22 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=24
+ /sbin/pidof -o %PPID named
+ '[' 24 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=26
+ /sbin/pidof -o %PPID named
+ '[' 26 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=28
+ /sbin/pidof -o %PPID named
+ '[' 28 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=30
+ /sbin/pidof -o %PPID named
+ '[' 30 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=32
+ /sbin/pidof -o %PPID named
+ '[' 32 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=34
+ /sbin/pidof -o %PPID named
+ '[' 34 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=36
+ /sbin/pidof -o %PPID named
+ '[' 36 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=38
+ /sbin/pidof -o %PPID named
+ '[' 38 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=40
+ /sbin/pidof -o %PPID named
+ '[' 40 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=42
+ /sbin/pidof -o %PPID named
+ '[' 42 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=44
+ /sbin/pidof -o %PPID named
+ '[' 44 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=46
+ /sbin/pidof -o %PPID named
+ '[' 46 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=48
+ /sbin/pidof -o %PPID named
+ '[' 48 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=50
+ /sbin/pidof -o %PPID named
+ '[' 50 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=52
+ /sbin/pidof -o %PPID named
+ '[' 52 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=54
+ /sbin/pidof -o %PPID named
+ '[' 54 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=56
+ /sbin/pidof -o %PPID named
+ '[' 56 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=58
+ /sbin/pidof -o %PPID named
+ '[' 58 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=60
+ /sbin/pidof -o %PPID named
+ '[' 60 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=62
+ /sbin/pidof -o %PPID named
+ '[' 62 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=64
+ /sbin/pidof -o %PPID named
+ '[' 64 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=66
+ /sbin/pidof -o %PPID named
+ '[' 66 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=68
+ /sbin/pidof -o %PPID named
+ '[' 68 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=70
+ /sbin/pidof -o %PPID named
+ '[' 70 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=72
+ /sbin/pidof -o %PPID named
+ '[' 72 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=74
+ /sbin/pidof -o %PPID named
+ '[' 74 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=76
+ /sbin/pidof -o %PPID named
+ '[' 76 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=78
+ /sbin/pidof -o %PPID named
+ '[' 78 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=80
+ /sbin/pidof -o %PPID named
+ '[' 80 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=82
+ /sbin/pidof -o %PPID named
+ '[' 82 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=84
+ /sbin/pidof -o %PPID named
+ '[' 84 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=86
+ /sbin/pidof -o %PPID named
+ '[' 86 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=88
+ /sbin/pidof -o %PPID named
+ '[' 88 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=90
+ /sbin/pidof -o %PPID named
+ '[' 90 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=92
+ /sbin/pidof -o %PPID named
+ '[' 92 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=94
+ /sbin/pidof -o %PPID named
+ '[' 94 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=96
+ /sbin/pidof -o %PPID named
+ '[' 96 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=98
+ /sbin/pidof -o %PPID named
+ '[' 98 -ge 100 ']'
+ sleep 2
+ echo -n .
.+ timeout=100
+ /sbin/pidof -o %PPID named
+ '[' 100 -ge 100 ']'
+ RETVAL=1
+ break
+ '[' 1 -eq 0 ']'
+ '[' -n '' -a x '!=' x/ ']'
+ '[' 1 -eq 0 ']'
+ failure
+ local rc=1
+ '[' color '!=' verbose -a -z '' ']'
+ echo_failure
+ '[' color = color ']'
+ echo -en '\033[60G'
+ echo -n '['
[+ '[' color = color ']'
+ echo -en '\033[0;31m'
+ echo -n FAILED
FAILED+ '[' color = color ']'

+ echo -en '\033[0;39m'
+ echo -n ']'
]+ echo -ne '\r'
+ return 1
+ '[' -x /usr/bin/rhgb-client ']'
+ return 1
+ echo

+ return 1
+ exit 1
---------------------------------------------------------------

---------------------------------------------------------------
# bash -x /etc/init.d/named start

+ . /etc/rc.d/init.d/functions
++ TEXTDOMAIN=initscripts
++ umask 022
++ PATH=/sbin:/usr/sbin:/bin:/usr/bin
++ export PATH
++ '[' -z '' ']'
++ COLUMNS=80
++ '[' -z '' ']'
+++ /sbin/consoletype
++ CONSOLETYPE=pty
++ '[' -f /etc/sysconfig/i18n -a -z '' ']'
++ . /etc/profile.d/lang.sh
+++ sourced=0
+++ for langfile in /etc/sysconfig/i18n '$HOME/.i18n'
+++ '[' -f /etc/sysconfig/i18n ']'
+++ . /etc/sysconfig/i18n
++++ LANG=en_US.UTF-8
++++ SYSFONT=latarcyrheb-sun16
+++ sourced=1
+++ for langfile in /etc/sysconfig/i18n '$HOME/.i18n'
+++ '[' -f /root/.i18n ']'
+++ '[' -n '' ']'
+++ '[' 1 = 1 ']'
+++ '[' -n en_US.UTF-8 ']'
+++ export LANG
+++ '[' -n '' ']'
+++ unset LC_ADDRESS
+++ '[' -n '' ']'
+++ unset LC_CTYPE
+++ '[' -n '' ']'
+++ unset LC_COLLATE
+++ '[' -n '' ']'
+++ unset LC_IDENTIFICATION
+++ '[' -n '' ']'
+++ unset LC_MEASUREMENT
+++ '[' -n '' ']'
+++ unset LC_MESSAGES
+++ '[' -n '' ']'
+++ unset LC_MONETARY
+++ '[' -n '' ']'
+++ unset LC_NAME
+++ '[' -n '' ']'
+++ unset LC_NUMERIC
+++ '[' -n '' ']'
+++ unset LC_PAPER
+++ '[' -n '' ']'
+++ unset LC_TELEPHONE
+++ '[' -n '' ']'
+++ unset LC_TIME
+++ '[' -n '' ']'
+++ unset LC_ALL
+++ '[' -n '' ']'
+++ unset LANGUAGE
+++ '[' -n '' ']'
+++ unset LINGUAS
+++ '[' -n '' ']'
+++ unset _XKB_CHARSET
++++ /sbin/consoletype
+++ consoletype=pty
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n en_US.UTF-8 ']'
+++ case $LANG in
+++ '[' xterm = linux ']'
+++ unset SYSFONTACM SYSFONT
+++ unset sourced
+++ unset langfile
++ '[' -z '' ']'
++ '[' -f /etc/sysconfig/init ']'
++ . /etc/sysconfig/init
+++ BOOTUP=color
+++ GRAPHICAL=yes
+++ RES_COL=60
+++ MOVE_TO_COL='echo -en \033[60G'
+++ SETCOLOR_SUCCESS='echo -en \033[0;32m'
+++ SETCOLOR_FAILURE='echo -en \033[0;31m'
+++ SETCOLOR_WARNING='echo -en \033[0;33m'
+++ SETCOLOR_NORMAL='echo -en \033[0;39m'
+++ LOGLEVEL=3
+++ PROMPT=yes
+++ AUTOSWAP=no
++ '[' pty = serial ']'
++ '[' color '!=' verbose ']'
++ INITLOG_ARGS=-q
++ __sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
+ '[' -r /etc/sysconfig/network ']'
+ . /etc/sysconfig/network
++ NETWORKING=yes
++ NETWORKING_IPV6=no
++ HOSTNAME=lnx2.ipaddress.com.ar
+ '[' -r /etc/sysconfig/named ']'
+ . /etc/sysconfig/named
+ export KRB5_KTNAME=/etc/named.keytab
+ KRB5_KTNAME=/etc/named.keytab
+ NAMED_SHUTDOWN_TIMEOUT=100
+ '[' -n '' ']'
+ RETVAL=0
+ named=named
+ [[ '' = [yY1]* ]]
+ prog=named
++ nmdcOption
++ let i=0
+ named_c_option=
+ named_conf=/etc/named.conf
+ dbusEnabled=0
+ '[' 0 -eq 0 ']'
+ '[' -z '' ']'
+ NetworkManagerEnabled=0
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=0 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=1 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=2 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=3 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=4 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=5 NetworkManager
+ for l in 0 1 2 3 4 5 6
+ /sbin/chkconfig --level=6 NetworkManager
+ '[' 0 -eq 1 ']'
+ dbusEnabled=1
+ case "$1" in
+ start
+ '[' -x /usr/sbin/named ']'
+ '[' '!' -r /etc/named.conf ']'
+ echo -n 'Starting named: '
Starting named: ++ /sbin/pidof -o %PPID named
+ '[' -n '27258 25652 10205 10063 4143' ']'
+ echo -n 'named: already running'
named: already running+ failure
+ local rc=0
+ '[' color '!=' verbose -a -z '' ']'
+ echo_failure
+ '[' color = color ']'
+ echo -en '\033[60G'
+ echo -n '['
[+ '[' color = color ']'
+ echo -en '\033[0;31m'
+ echo -n FAILED
FAILED+ '[' color = color ']'
+ echo -en '\033[0;39m'

+ echo -n ']'
]+ echo -ne '\r'
+ return 1
+ '[' -x /usr/bin/rhgb-client ']'
+ return 0
+ echo

+ return 1
+ exit 1
---------------------------------------------------------------

I've run the commands in the order i've post them.
The start is telling me: "named: already running+ failure"
However i've just stop it (it fails, but named is stoped)
Where could be the problem? Any ideas?

Bye!
 
There already is "-u named" in there, no need to specify it twice. The error is elsewhere.
Use "bash +x /etc/init.d/named start".

You must of looked at a diff line then me. Wtf does +x do?
 
Do you see how important is it to copy/paste the exact errors and messages when some command fails? If instead of looking for "how to run named with user named" you just copied the output of "/etc/init.d/named stop" I would have given you the answer: bind is stuck; "rndc stop" doesn't kill it because it's freezed.

Just run "killall -9 named && /etc/init.d/named start", it should work.
If the start fails, it's because DA has already restarted it (it check the service every minute)... that's why it's better to run the two commands at the same time with two "and" signs in between: named will be started just after being killed.

If it happens again you may want to reinstall or recompile (if not precompiled) bind and check your config. If it's the config, you found a new bug.
 
You must of looked at a diff line then me. Wtf does +x do?
The line is:
Code:
daemon /usr/sbin/$named -u named ${OPTIONS};
The -x parameter makes bash and all of its bash childs to print every command and function before running them.
 
Do you see how important is it to copy/paste the exact errors and messages when some command fails? If instead of looking for "how to run named with user named" you just copied the output of "/etc/init.d/named stop" I would have given you the answer: bind is stuck; "rndc stop" doesn't kill it because it's freezed.

Just run "killall -9 named && /etc/init.d/named start", it should work.
If the start fails, it's because DA has already restarted it (it check the service every minute)... that's why it's better to run the two commands at the same time with two "and" signs in between: named will be started just after being killed.

If it happens again you may want to reinstall or recompile (if not precompiled) bind and check your config. If it's the config, you found a new bug.

# killall -9 named && /etc/init.d/named start
KFails when it try to start named. The problem is the same.

I still think the problem is the user that /etc/init.d/named use to start the service.
Cause when i use the command "named -u named" the service works fine, and when i use "/etc/init.d/named start" it fails.

I dont fully understand how /etc/init.d/named starts the daemon, however im trying to find the error. I've made a change in the file:
---------------------------------------------------------------------
...
echo HERE1
if [ $conf_ok -eq 1 ]; then
echo HERE2
daemon /usr/sbin/$named -u named ${OPTIONS};
...
---------------------------------------------------------------------
i've ran the command you gave me and it fails, but shows me "HERE1" but no "HERE2". So maybe something in the configuration could be wrong.
But i dont know what :(



Thanks for all the help :)
 
You are on the right path but stop thinking about the username, it has nothing to do with your problem. As I said, the script already takes care of that.

Take a look at this snippet:
Code:
conf_ok=0;
if [ -x /usr/sbin/named-checkconf ] && [ -x /usr/sbin/named-checkzone ] && /usr/sbin/named-checkconf $ckcf_options ${named_conf} >/dev/null 2>&1; then
conf_ok=1;
The start script now fails because of that.

First check that those two binaries are there, if they aren't reinstall bind.
If they are, run /usr/sbin/named-checkconf with "-z /etc/named.conf" as arguments.
 
# named-checkconf -z /etc/named.conf
------------------------------------------------------------
rev/xxx.yyy.zzz:w: no TTL specified; using SOA MINTTL instead
zone 135.69.200.in-addr.arpa/IN: loaded serial 2007100901
rev/xxx.yyy.zzz:w: no TTL specified; using SOA MINTTL instead
zone 170.80.200.in-addr.arpa/IN: loaded serial 2008020802
rev/aaa.bbb.ccc:d: no TTL specified; using SOA MINTTL instead
zone 60.61.200.in-addr.arpa/IN: loaded serial 2008011801
rev/xxx.yyy.zzz:w: no TTL specified; using SOA MINTTL instead
zone 209.80.200.in-addr.arpa/IN: loaded serial 2008011801
zone Domain1.com.ar/IN: loaded serial 2009050802
zone Domain2.com.ar/IN: loaded serial 2009050801
zone Domain3.com.ar/IN: loaded serial 2009050800
zone Domain4.es/IN: loaded serial 2009050802
zone Domain5.es/IN: loaded serial 2009050802
zone Domain6.es/IN: loaded serial 2009050801
zone Domain7.com/IN: loaded serial 2009050800
zone Domain8.com/IN: loaded serial 2009050801
...
... (A lot more of this, with different Domains)
...
------------------------------------------------------------

I cant see any problem in the configuration, so i dont understand why /etc/init.d/named fails cheking it.
Can you see any problem with the output of the configuration?

Bye!
 
Run that command again then run "echo $?". The output should be "0". If it isn't, there must be an error in the output somewhere. If it's "0", something is very wrong... but I can't think of what without having access to your system.
 
Run that command again then run "echo $?". The output should be "0". If it isn't, there must be an error in the output somewhere. If it's "0", something is very wrong... but I can't think of what without having access to your system.

# echo $?
1

So, theres an error in the output...
However all the output i get is:
"rev/XXX.YYY.ZZZ:W: no TTL specified; using SOA MINTTL instead"
or
"zone SomeDomain.com.ar/IN: loaded serial 2009050802"

And for what i know, thats nos en error, or is it?
Thanks!


Bye.
 
No, those are not... but an error must be there.

The program doesn't just crash, because when a program gets a signal and exists bash sets 128 + signal number, so a segfault should let "139" as return code. A return of "1" means that named-checkconf exits with that return code, which generally means "fatal error".

Try running the same program without "-z" and check the return code.
If it's "0", it means that the error is in one of the master zone files and you must see it somewhere in the output when using "-z". If you can't find it just copy it here, or send it to me as private message.
If it's "1" the error is not in the master zone files, but you should see something anyway... in that case copy/send also the content of named.conf so that we can check it.
 
Why not just use a different init file?

Something simple like:

Code:
#!/bin/sh

case "$1" in

start)
/usr/sbin/named -u named
echo ""
echo "Named started: [ OK ]"
echo ""
;;

stop)
ps xua | grep -v grep | grep 'named' | xargs kill 2>&1 /dev/null
echo ""
echo "Named stopped: [ OK ]"
echo ""
;;

restart)
ps xua | grep -v grep | grep 'named' | xargs kill 2>&1 /dev/null
/usr/sbin/named -u named
echo ""
echo "Named restarted: [ OK ]"
echo ""
;;

*|help)
echo ""
echo "Usage: $0 start | stop | restart | help"
echo ""
;;

esac
 
I'd rather find the root of this error. A workaround must be a temporary solution, and by now he already has a temporary solution: to run "named -u named" manually.
One day this weird error may prevent named from running at all, and there will be no workaround; this means that his DNS service will be down until he finds the root of this error. Yep, I'd rather find it now :)
 
I'd rather find the root of this error. A workaround must be a temporary solution, and by now he already has a temporary solution: to run "named -u named" manually.
One day this weird error may prevent named from running at all, and there will be no workaround; this means that his DNS service will be down until he finds the root of this error. Yep, I'd rather find it now :)

# named-checkconf /etc/named.conf
# echo $?
0

# named-checkconf -z /etc/named.conf >> /root/output.txt
I start to read output.txt (i takes time, its reaaally long!) and i found:
"_default/OneOfMyDomains.com.ar/IN: bad zone"
The zone had incorrect values. I've correct them and now its all working!
I can manipulate named with "/etc/init.d/named" and with Directadmin.

Thank you all for helping me with this :)

Bye!
 
Back
Top