#!/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

. /etc/colorrc

test -f /etc/aldccp/network || exit 0
. /etc/aldccp/network

test -f /usr/sbin/udhcpd || exit 0
test -f /etc/udhcpd.conf || exit 0


case "$1" in
    start)
	if test x$NETWORKING = x"yes" -a  x$UDHCPD_START = x"yes" -a  x$NET0_START = x"yes"; then
	  if checkproc /usr/sbin/udhcpd; then
	      echo "/usr/sbin/udhcpd: is running $rc_Err"
	      exit 1
	  fi
	  echo -n "Starting udhcpd ... "
	  /usr/sbin/udhcpd
	  if test $? != 0; then
	      echo "$rc_Err"
	      exit 1
	  fi
	  echo "$rc_Ok"
	else
	  $0 stop
	fi
	;;
    stop)
	if checkproc /usr/sbin/udhcpd; then
	    echo -n "Shut Down udhcpd daemon... "
	    killproc udhcpd
	    if test $? != 0; then
		echo "$rc_Err"
	    else
		echo "$rc_Ok"
	    fi
	fi
	;;
    *)
	echo "Usage: {start|stop}"
	exit 1
	;;
esac
