#!/bin/sh

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

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC=udhcpc
DAEMON=udhcpc
IFACE=eth0
PIDFILE=/var/run/udhcpc.$IFACE.pid

set -e

case $1 in
	start)
		echo -n "Starting $DESC: "
		start-stop-daemon --start -p $PIDFILE $DAEMON -- -R -b -p /var/run/udhcpc.$IFACE.pid -i $IFACE
	;;
	stop)
		echo -n "Stopping $DESC: "
		if [ -e $PIDFILE ];then
			start-stop-daemon --stop -s SIGKILL -p $PIDFILE $DAEMON
			rm $PIDFILE
		fi;
	;;
	restart|force-reload)
		$0 stop
		sleep 1
		$0 start
	;;
	status)
		status ${DAEMON} || exit $?
	;;
	*)
		N=/etc/init.d/udhcpc
		echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
		exit 1
	;;
esac

exit 0
