Author Topic: DHCP rc script from ISO README  (Read 321 times)

0 Members and 1 Guest are viewing this topic.

razwall

  • Administrator
  • Jr. Member
  • *****
  • Posts: 58
    • View Profile
DHCP rc script from ISO README
« on: March 07, 2025, 08:47:25 AM »
RC script for DHCP
------------------

A Slackware start/stop script for the DHCP server that you can save as
"/etc/rc.d/rc.dhcpd".

Don't forget to make the script executable:

  chmod +x /etc/rc.d/rc.dhcpd

You can add the following lines to /etc/rc.d/rc.local so that the DHCP
service starts when your server boots:

if [ -x /etc/rc.d/rc.dhcpd ]; then
  # Start the DHCP server:
  /etc/rc.d/rc.dhcpd start
fi

This is the content of the file "/etc/rc.d/rc.dhcpd":

#!/bin/sh
#
# /etc/rc.d/rc.dhcpd
#      This shell script takes care of starting and stopping
#      the ISC DHCPD service
#

# Put the command line options here that you want to pass to dhcpd:
DHCPD_OPTIONS="-q eth0"

[ -x /usr/sbin/dhcpd ] || exit 0

[ -f /etc/dhcpd.conf ] || exit 0

start() {
      # Start daemons.
      echo -n "Starting dhcpd:  /usr/sbin/dhcpd $DHCPD_OPTIONS "
      /usr/sbin/dhcpd $DHCPD_OPTIONS
      echo
}
stop() {
      # Stop daemons.
      echo -n "Shutting down dhcpd: "
      killall -TERM dhcpd
      echo
}
status() {
  PIDS=$(pidof dhcpd)
  if [ "$PIDS" == "" ]; then
    echo "dhcpd is not running!"
  else
    echo "dhcpd is running at pid(s) ${PIDS}."
  fi
}
restart() {
      stop
      start
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  status)
        status
        ;;
  *)
        echo "Usage: $0 {start|stop|status|restart}"
        ;;
esac

exit 0