You are not logged in.

#1 2004-09-01 22:19:57

IceRAM
Member
From: Bucharest, Romania
Registered: 2004-03-04
Posts: 772
Website

Sugestion for /etc/rc.d/dnsmasq daemon script

Well, I'm not really sure this is the right place... but I'll drop it here.

I have one tiny sugestion for the dnsmasq daemon.
I've seen on the net that there are some cases (such as name caching) when a new resolv file is needed to be passed as a parameter. I can say this is a quite frequent situation when people want just name caching for both the local computer and the other computers.

The following code snippet covers this situation also.

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

PID=`pidof -o %PPID /usr/sbin/dnsmasq`
case "$1" in
  start)
    _param="" && _ns=0
    [ -f "/etc/resolv.dnsmasq" ] && _ns=`cat /etc/resolv.dnsmasq | grep -v "^[ ]*$" | grep -v "^#.*" | wc -l`
    [ $_ns -gt 0 ] && _param="-r /etc/resolv.dnsmasq"
    stat_busy "Starting DNS/DHCP daemon"
    [ -z "$PID" ] && (/usr/sbin/dnsmasq $_param)
    if [ $? -gt 0 ] ; then
      stat_fail
    else
      add_daemon dnsmasq                     # create the 'state' dir
      stat_done
    fi
    ;;
  stop)
# ...

It would be nice though if, in the install file (which doesn't exist yet) there could be put some echo(-ed) lines mentioning:

Alternative name servers can be used by creating /etc/resolv.dnsmasq similar to /etc/resolv.conf.
If /etc/resolv.dnsmasq is missing, the default /etc/resov.conf file is used.

Code details:
_param="" && _ns=0
Init code: param is set to null and the number of alternative nameservers is set to zero

[ -f "/etc/resolv.dnsmasq" ] && _ns=`cat /etc/resolv.dnsmasq | grep -v "^[ ]*$" | grep -v "^#.*" | wc -l`
= if /etc/resolv.dnsmasq exists, count in _ns the valid nameserver lines in it (non-empty & non-comment)

[ $_ns -gt 0 ] && _param="-r /etc/resolv.dnsmasq"
if the number of alternative nameservers (_ns)>0 then use "-r /etc/resolv.dnsmasq" as parameter, otherwise the param remains null.

Offline

#2 2004-09-01 23:31:13

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: Sugestion for /etc/rc.d/dnsmasq daemon script

To quote the manpage:

CONFIG FILE
       At  startup, dnsmasq reads /etc/dnsmasq.conf, if it exists. (On FreeBSD
       and OpenBSD, the file is  /usr/local/etc/dnsmasq.conf)  The  format  of
       this  file consists of one option per line, exactly as the long options
       detailed in the OPTIONS section but without  the  leading  "--".  Lines
       starting with # are comments and ignored.

Why bothering with your hassle when you can simply use "resolv-file=<file>" in /etc/dnsmasq.conf?

Offline

#3 2004-09-02 07:26:39

IceRAM
Member
From: Bucharest, Romania
Registered: 2004-03-04
Posts: 772
Website

Re: Sugestion for /etc/rc.d/dnsmasq daemon script

I'm using

Name           : dnsmasq
Version        : 2.13-1

This version does not come with a sample /etc/dnsmasq.conf file.
I don't find that really pleasant, considering that all the other server programs (bind, samba etc.) come with such a file. An unexperienced user might think that it works out of the box.

Another idea then...
Why not include a sample config file with all those lines commented?
Modifying an existing file will make a user's life much more pleasant than creating a new one from scratch.

Offline

#4 2004-09-02 11:20:17

farphel
Forum Fellow
From: New Hampshire - USA
Registered: 2003-09-18
Posts: 250
Website

Re: Sugestion for /etc/rc.d/dnsmasq daemon script

IceRAM wrote:

Another idea then...
Why not include a sample config file with all those lines commented?
Modifying an existing file will make a user's life much more pleasant than creating a new one from scratch.

Sounds like a good idea.  Do me a favor though, and file this as a bug report so I don't forget about it.  I can write up a basic config file and heavily comment it based on the man page.

Personally, I just read the man page and made my own config file, but I can see your point that not having a sample (or simple) config file created with the package is installed can be misleading.

Cheers,
farphel


Follow the link below, sign up, and accept one promotional offer.  If I can get five suckers (err... friends) to do this, I'll get a free iPod.  Then you too can try to get a free iPod. Thanks! http://www.freeiPods.com/?r=11363142

Offline

#5 2004-09-02 20:09:11

IceRAM
Member
From: Bucharest, Romania
Registered: 2004-03-04
Posts: 772
Website

Re: Sugestion for /etc/rc.d/dnsmasq daemon script

I did make an task in FlySpray... but I've changed my mind (again - sorry).
This file should be provided by the original package.. shouldn't it?

Offline

#6 2004-09-06 17:49:00

IceRAM
Member
From: Bucharest, Romania
Registered: 2004-03-04
Posts: 772
Website

Re: Sugestion for /etc/rc.d/dnsmasq daemon script

The last dnsmasq version (2.13-2 - which includes a sample commented config file) does not put it in the right place.
The when I start the daemon with "/etc/rc.d/dnsmasq start" /etc/dnsmasq/dnsmasq.conf is ignored.

To be take into account, the conf file should be put directly in /etc/dnsmasq.conf. This is not really obvious, because some other programs like their config files in separate subdirs of /etc (such as X.org). I first thought the same thing, but while reading the man page I've noticed in the end a short refference to /etc/dnsmasq.conf.
Moving /etc/dnsmasq/dnsmasq.conf to /etc/dnsmasq.conf solves the problem, with no change to the daemon script.

Should I add another FlySpray task?

P.S. dnsmasq has some nice options there... I bet not many users knew about them.

Offline

#7 2004-09-06 17:51:21

farphel
Forum Fellow
From: New Hampshire - USA
Registered: 2003-09-18
Posts: 250
Website

Re: Sugestion for /etc/rc.d/dnsmasq daemon script

*sighs*  If only I was careful enough to read the docs...

Nah, you don't need to do another flyspray task.  I'll fix it up on a few minutes.


Follow the link below, sign up, and accept one promotional offer.  If I can get five suckers (err... friends) to do this, I'll get a free iPod.  Then you too can try to get a free iPod. Thanks! http://www.freeiPods.com/?r=11363142

Offline

#8 2004-09-06 18:27:54

IceRAM
Member
From: Bucharest, Romania
Registered: 2004-03-04
Posts: 772
Website

Re: Sugestion for /etc/rc.d/dnsmasq daemon script

backup line sad...
Please...

IceRAM

Offline

Board footer

Powered by FluxBB