#!/bin/sh

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

BINFILE='/opt/sbin/bandwidthd'
PIDFILE='/opt/var/run/bandwidthd.pid'

status()
{
        [ -f $PIDFILE ] && [ -d /proc/`cat $PIDFILE` ]
}

start() {
	$BINFILE
#	logger -s -t bandwidthd "service starting... "
}

stop() {
	kill `cat $PIDFILE` | rm $PIDFILE
#        logger -s -t bandwidthd "service stopping... "
}

case "$1" in
        start)
                if status
                then
                        echo bandwidthd already running
                else
                        start
                fi
                ;;
        stop)
                if status
                then
                        stop
                else
                        echo bandwidthd is not running
                fi
                ;;
	status)
		if status
		then
			echo bandwidthd running
		else
			echo bandwidthd is not running
		fi
		;;
	*)
		echo "Usage: $0 {start|stop|status}"
esac
