Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] /etc/init.d/named asks for extra options
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
stillman
Apprentice
Apprentice


Joined: 07 Dec 2002
Posts: 223
Location: Vienna, Austria

PostPosted: Thu Aug 11, 2005 1:44 pm    Post subject: [SOLVED] /etc/init.d/named asks for extra options Reply with quote

i've configured bind and it starts fine with
Code:
/usr/sbin/named -u named -n 1 -g -c /etc/bind/named.conf -d 9 -t /chroot/dns
but running it with the runscript /etc/init.d/named says:
Code:

/etc/init.d/named start
 * Starting chrooted named ...
usage: named [-c conffile] [-d debuglevel] [-f|-g] [-n number_of_cpus]
             [-p port] [-s] [-t chrootdir] [-u username]
named: extra command line arguments                                                              [ !! ]


i've added the flags in the first command to /etc/conf.d/named but that doesn't seem to have any effect. thx for your suggestions...


Last edited by stillman on Sat Aug 13, 2005 8:50 am; edited 3 times in total
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Thu Aug 11, 2005 3:02 pm    Post subject: Reply with quote

I'd think /etc/conf.d/named would need to look like this. You shouldn't need the -c since that's the default location in the /etc/init.d/named script. That script also adds -u named as well.

Code:

# Set various named options here.
#
OPTIONS="-g -d 9"

# Set this to the number of processors you have.
#
CPU="1"

# If you wish to run bind in a chroot, run:
# ebuild /var/db/pkg/net-dns/<bind version>/<bind-version> config
# and un-comment the following line.
# You can specify a different chroot directory but MAKE SURE it's empty.
CHROOT="/chroot/dns"


kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
stillman
Apprentice
Apprentice


Joined: 07 Dec 2002
Posts: 223
Location: Vienna, Austria

PostPosted: Thu Aug 11, 2005 3:29 pm    Post subject: Reply with quote

yupp, after having a closer look at the init.d-file i'm more puzzled. i've tried to change the start-stop command to one line - instead of
Code:
 start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
                --exec /usr/sbin/named \
        -- -u named -n ${CPU} ${OPTIONS} ${CHROOT:+-t $CHROOT}

to
Code:
 start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
                --exec /usr/sbin/named -u named -n ${CPU} ${OPTIONS} ${CHROOT:+-t $CHROOT}


and it works
Code:
/etc/init.d/named start
 * Re-caching dependency info (mtimes differ)...
 * Starting chrooted named ...
Would start /usr/sbin/named // location of pid file /chroot/dns .                                          [ ok ]

(as long as i don't add options in /etc/conf.d/named else the script cries for not knowing the flag). but i'm not really happy with that...

[edit]ok, actually it doesn't work, it just pretends to have started - without error messages


Last edited by stillman on Thu Aug 11, 2005 3:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Thu Aug 11, 2005 3:33 pm    Post subject: Reply with quote

Weird, though not surprising. The Gentoo named startup scripts have always had strange issues like trying to put the pid file into directories that it doesn't have enough priveledge to write to and nonsense like that.

I'd look around bugzilla and file a bug if there isn't one already.

kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
stillman
Apprentice
Apprentice


Joined: 07 Dec 2002
Posts: 223
Location: Vienna, Austria

PostPosted: Thu Aug 11, 2005 3:40 pm    Post subject: Reply with quote

plz check my last edit. actually i'm using the same ebuild as the one you've used in your gentoo-wiki -> 9.2.5-r4
so why should it not work in my case? or don't you start it as a service?
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Thu Aug 11, 2005 3:46 pm    Post subject: Reply with quote

hmmm I'm currently not chrooting and not adding any flags so the problem is either there or in your config. Is there anything in your logs and does a named-checkconf come back clean?

kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
stillman
Apprentice
Apprentice


Joined: 07 Dec 2002
Posts: 223
Location: Vienna, Austria

PostPosted: Thu Aug 11, 2005 3:51 pm    Post subject: Reply with quote

yes, no probs at all. i'm currently working with this nameserver started manually(and only this ns). the init-script doesn't work with flags either, it just responds everything is working(i switched back to the old syntax and get the message in my first post). can you post your named-init-script plz? thanks for your interest so far.
Back to top
View user's profile Send private message
stillman
Apprentice
Apprentice


Joined: 07 Dec 2002
Posts: 223
Location: Vienna, Austria

PostPosted: Thu Aug 11, 2005 4:42 pm    Post subject: Reply with quote

hmm, updating to 9.3.1 and overwriting init.d/named didn't solve it either - going to file a bug report...
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Thu Aug 11, 2005 4:49 pm    Post subject: Reply with quote

You know that might it. I helped morphal out last week or so and his /etc/init.d/named script was different from mine. Once we swapped his for mine he had no problems.

My script assumes that you have a /var/run/named dir and it's owned by named:named. You might want to create it or edit my script.

kashani

Code:

#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.rc6,v 1.15 2004/07/14 23:18:19 agriffis
Exp $

opts="start stop reload restart"

depend() {
        need net
        use logger
        provide dns
}

checkconfig() {
        if [ ! -f ${CHROOT}/etc/bind/named.conf ] ; then
                eerror "No ${CHROOT}/etc/bind/named.conf file exists!"
        fi

        # In case someone doesn't have $CPU set from /etc/conf.d/named
        if [ ! $CPU ] ; then
                CPU=1
        fi

        if [ $CHROOT -a -d $CHROOT ] ; then
                PIDFILE="${CHROOT}/var/run/named/named.pid"
                KEY="${CHROOT}/etc/bind/rndc.key"
        else
                PIDFILE="/var/run/named/named.pid"
                KEY="/etc/bind/rndc.key"
        fi
}

start() {
        ebegin "Starting ${CHROOT:+chrooted }named"
        checkconfig || return 1
        start-stop-daemon --start --quiet --exec /usr/sbin/named \
                --pid ${CHROOT}/var/run/named/named.pid \
                -- -u named -n $CPU $OPTIONS ${CHROOT:+-t $CHROOT}
        eend $?
}

stop() {
        ebegin "Stopping ${CHROOT:+chrooted }named"
        checkconfig || return 2
        start-stop-daemon --stop --quiet --pidfile $PIDFILE \
                --exec /usr/sbin/named -- stop
        eend $?
}

reload() {
        checkconfig || return 3
        if [ ! -f $PIDFILE ] ; then
                /etc/init.d/named start &>/dev/null
                exit
        fi

        if [ -f $KEY ] ; then
                ebegin "Reloading named.conf and zone files"
                rndc -k $KEY reload &>/dev/null
                eend $?
        else /etc/init.d/named restart &>/dev/null
        fi
}

restart() {
        svc_stop
        svc_start
}

_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Thu Aug 11, 2005 5:00 pm    Post subject: Reply with quote

That may work with baselayout-1.12.0_pre5 as I didn't know that s-s-d supports the --pid option

pre6 will support it. baselayout-1.11.x and earlier don't intercept s-s-d calls so that should work.

In the meantime, use the --pidfile option like it's used in the stop() function in your script
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
stillman
Apprentice
Apprentice


Joined: 07 Dec 2002
Posts: 223
Location: Vienna, Austria

PostPosted: Thu Aug 11, 2005 5:16 pm    Post subject: Reply with quote

well, 9.3.1-r3 uses the --pidfile syntax. my named-script looks like this now:
Code:
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.rc,v 1.1 2005/08/03 16:54:38 voxus Exp $

opts="start stop reload restart"

depend() {
        need net
        use logger
        provide dns
}

checkconfig() {
        if [ ! -f ${CHROOT}/etc/bind/named.conf ] ; then
                eerror "No ${CHROOT}/etc/bind/named.conf file exists!"
        fi

        # In case someone doesn't have $CPU set from /etc/conf.d/named
        if [ ! ${CPU} ] ; then
                CPU="1"
        fi

        # As with the named.conf test, above, there's no need
        # for chroot and non-chroot cases here
        PIDFILE=$(grep "pid-file" ${CHROOT}/etc/bind/named.conf | \
                egrep -v ".*[#,//].*pid-file" | \
                head -n 1 | \
                sed -ne 's:.*pid-file\(.*\)\"\(.*\)\";:\2:p')
        [ -n "$PIDFILE" ] || PIDFILE=/var/run/named.pid

        PIDFILE="${CHROOT}$PIDFILE"

        KEY="${CHROOT}/etc/bind/rndc.key"
}

start() {
        ebegin "Starting ${CHROOT:+chrooted }named"
        checkconfig || return 1
        start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
                --exec /usr/sbin/named \
                -- -u named -n ${CPU} ${OPTIONS} ${CHROOT:+-t $CHROOT}
        eend $?
}

stop() {
        ebegin "Stopping ${CHROOT:+chrooted }named"
        checkconfig || return 2
        start-stop-daemon --stop --quiet --pidfile $PIDFILE \
                --exec /usr/sbin/named -- stop
        eend $?
}

reload() {
        checkconfig || return 3
        if [ ! -f $PIDFILE ] ; then
                /etc/init.d/named start &>/dev/null
                exit
        fi

        if [ -f $KEY ] ; then
                ebegin "Reloading named.conf and zone files"
                rndc -k $KEY reload &>/dev/null
                eend $?
        else /etc/init.d/named restart &>/dev/null
        fi
}

restart() {
        svc_stop
        svc_start
}
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Thu Aug 11, 2005 5:28 pm    Post subject: Reply with quote

If you are a baselayout-1.12.0_pre user, does it now work for you?

EDIT: AFAIK there's a known bug with s-s-d which returns an OK when named is started with an invalid config file, baselayout-1.12.0_pre should fix that as we wait 0.1 seconds to check the daemon is still running. Asterisk is another other badly written daemon with the same issue.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
stillman
Apprentice
Apprentice


Joined: 07 Dec 2002
Posts: 223
Location: Vienna, Austria

PostPosted: Thu Aug 11, 2005 5:35 pm    Post subject: Reply with quote

no, it's a production server so i have 1.11.13. guess i'll also downgrade to bind 9.2.5 again. having added the stuff to local.start and local.stop in the meanwhile since i don't really see through how the start-stop-daemon works with starting(stopping is easier). thanks for your help!

Edit: it works with kashanis script. got no concentration left to analyze it but thank you sir!
Back to top
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Thu Aug 11, 2005 9:46 pm    Post subject: Reply with quote

Finally got a chance to test this on my private box. baselayout 1.11.13 works fine with 9.3.1 however your options are goofy. -g means run named in the foreground. As soon as you get any entry on the command line it exits. Is that the behavior you want?

kashani
_________________
Will personally fix your server in exchange for motorcycle related shop tools in good shape.
Back to top
View user's profile Send private message
stillman
Apprentice
Apprentice


Joined: 07 Dec 2002
Posts: 223
Location: Vienna, Austria

PostPosted: Sat Aug 13, 2005 8:48 am    Post subject: Reply with quote

nope, that was just for testing. thx!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum