#!/bin/sh
########################################################################
# Begin dhcpd
#
# Description	: ISC DHCP Server Boot Script.
#
# Author	: 
#
# Version	: LFS 7.0
# chkconfig	: 2345 65 35
#
########################################################################

### BEGIN INIT INFO
# Provides:            $dhcpd
# Required-Start:      $network
# Required-Stop:       sendsignals
# Default-Start:       2 3 4 5
# Default-Stop:        0 2 6
# Short-Description:   Starts the ISC DHCP Server.
# X-LFS-Provided-By:   BLFS
### END INIT INFO

. /lib/lsb/init-functions

#$LastChangedBy: krejzi $
#$Date: 2013-06-11 10:49:17 -0500 (Tue, 11 Jun 2013) $

#$LastChangedBy: jmp $
#$Date Thursday, March 14 2019 10:02:20 $

INTERFACES=""
OPTIONS=""

IPV=4
PROG=dhcpd
DHCPD=/usr/sbin/${PROG}
CONFIG=/etc/dhcp/${PROG}.conf
SYSCONF=/etc/sysconfig/${PROG}
PID_FILE=/var/run/${PROG}.pid


if [ -f "$SYSCONF" ]; then
  . $SYSCONF
  fi

case "$1" in
   start)

      if [ -z "$INTERFACES" ]; then
         MSG="You need to configure dhcp server in"
         log_warning_msg "$MSG /etc/sysconfig/${PROG}"
         exit 0
      fi

      if [ ! -f "$CONFIG" ]; then
         MSG="config file \"$CONFIG\" is missing, aborting"
         log_warning_msg "$MSG"
         exit 0
      fi
      log_info_msg "Starting ISC DHCP Server dhcpd"
      start_daemon $DHCPD 					\
	      	-$IPV						\
	      	-user $PROG					\
		-group $PROG					\
		-cf $CONFIG					\
		-pf $PID_FILE					\
	      	-q $INTERFACES $OPTIONS
      evaluate_retval

      ;;

   stop)

      log_info_msg "Stopping ISC DHCP Server dhcpd"
      killproc -p $PID_FILE $DHCPD
      evaluate_retval

      ;;

   restart)
      $0 stop
      sleep 1
      $0 start
      ;;

    condrestart)
      pid=`cat $PID_FILE 2>/dev/null`
      if [ -n "${pid}"  -a -d /proc/$pid ]; then
        $0 restart
	fi
      ;;

   status)
      statusproc /usr/sbin/dhcpd
      ;;

   *)
      echo "Usage: $0 {start|stop|restart|status}"
      exit 1
      ;;
esac

# End /etc/init.d/dhcpd
