LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Missing /etc/init.d/dhcpd from ISC DHCPD (https://www.linuxquestions.org/questions/linux-networking-3/missing-etc-init-d-dhcpd-from-isc-dhcpd-597532/)

Quigi 11-06-2007 10:16 AM

Missing /etc/init.d/dhcpd from ISC DHCPD
 
The good: I got tired of my Belkin router switching around IP addresses. So I downloaded DHCPD (Dynamic Host Configuration Protocol Daemon) from the Internet Systems Consortium, http://www.isc.org/sw/dhcp/. It built without a hitch (./configure; make; sudo make install) and runs well. I can tie "static" IPs to our 5 MAC addresses. BTW, the machine is on FC2, so yum dried up.

The ugly: The usual setup has a script /etc/init.d/dhcpd, symlinked into the appropriate runlevels. This makes dhcpd start at boot time, and simplifies administration. That part wasn't set up by "make install". (I have to start (/usr/sbin/)dhcpd manually after a reboot.)

I looked through the directory tree, and see it only in one place: contrib/dhcp.spec looks like a RPM specification, and it supports only Solaris. I could try contrib/solaris.init and maybe adapt it. But I wonder how everyone else does this. Searched LQ and Google, no luck.

Hoping Networking is the right category -- DHCP(D) isn't explicitly listed in the guidelines. Thanks for any advice or other insights!

/Quigi

veerain 11-06-2007 09:43 PM

Check this site for scripts: http://smarden.org/runit/runscripts.html

Quigi 11-06-2007 10:00 PM

Hi contusion, thanks for the link. While I like daemontools, I was looking for the /etc/init.d style script, which is the usual way to control services under Fedora Core, Ubuntu, Solaris, and probably a few others.

E.g., dhcp-3.1.0/contrib/solaris.init looks like this (and would get installed as /etc/init.d/dhcpd):
Code:

#!/bin/sh
# Contributed by Brian Murrell
 
state=$1
 
set `who -r`
case $state in
 
'start')
        if [ $9 = "2" -o $9 = "3" ]
        then
                exit
        fi
        if [ -f @PREFIX@/sbin/dhcpd ]; then
                echo "Starting the ISC DHCP server"
                @PREFIX@/sbin/dhcpd
        fi
        ;;
'stop')
        if [ -f @PREFIX@/etc/dhcpd.pid ]; then
                PID=`cat @PREFIX@/etc/dhcpd.pid`
                if [ -d /proc/$PID ]; then
                        echo "Stopping the ISC DHCP server"
                        kill $PID
                fi
        fi
        ;;
esac

In my case it's /usr/sbin/dhcpd and /var/run/dhcpd.pid. And my runlevels might differ.

Wasskinny 03-26-2008 08:11 AM

Init Script, SysV for ISC DHCPD 4
 
Little fooling around and this is what I have. I thought it was interesting the distro didn't come with one. Improvements welcome.

Code:

#!/bin/sh
#
# dhcpd                Init Script to start/stop dhcpd.
#
# chkconfig:        - 61 39
# description:        If you dont know you shouldnt be here
#
# processname: dhcpd
config_file=/etc/dhcpd.conf
pidfile=/var/run/dhcpd.pid
lease_file=/var/db/dhcpd.leases


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

# Get network config
. /etc/sysconfig/network

  if [ ! -e $config_file ]; then
    echo " No config file at $config_file"
    exit 0
  fi

RETVAL=0

start() {
  if [ ! -e $lease_file ]; then
        echo "  Creating $lease_file"
        touch $lease_file

  elif [ -f $pidfile ]; then
        PID=`cat $pidfile`
        echo "    ISC-DHCPD already running: $PID"
        exit 2;
  else
        echo -n $"Starting ISC-DHCPD: "
        daemon /usr/local/sbin/dhcpd -q
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd               
        return $RETVAL
  fi
}

stop() {
        echo -n $"Stopping ISC-DHCPD: "
        killproc dhcpd
        RETVAL=$?
        echo
[ $RETVAL -eq 0 ] && rm -f /var/run/dhcpd.pid /var/lock/subsys/dhcpd
        return $RETVAL
}

restart() {
        stop
        start
}

reload() {
        echo -n $"Reloading dhcpd: "
        killproc dhcpd -USR2
        RETVAL=$?
        echo
        return $RETVAL
}


case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status dhcpd
        ;;
  restart)
        restart
        ;;
  condrestart)
        [ -f /var/lock/subsys/dhcpd ] && restart || :
        ;;
  reload)
        reload
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
        exit 1
esac

exit $?


Quigi 03-27-2008 08:50 PM

Thank you very much, Wassinsky!
I put i in place, 'status' and 'stop' worked flawlessly, 'start' will need some tweaking.

Yes, I was surprised too that ISC's tarball didn't supply the file. I assume every distro (e.g., ubuntu) adds one.


All times are GMT -5. The time now is 07:22 PM.