#!/bin/bash
# ucd-snmp init file for snmpd
#
# chkconfig: - 50 50
# description: SMS v1.0 SNMP Ex-Agent
#
# processname: /usr/local/smsagent/srmagent
# config: /usr/local/smsagent/snmpd.conf
# config: /usr/local/smsagent/snmpd.conf
# pidfile: /var/run/srmagent

# source function library
#. /etc/init.d/functions
Path="/usr/local/smsagent"
prog="Smsagent"
SRMAGENT="/usr/local/smsagent/srmagent"

. /etc/rc.status
rc_reset

test -x $SRMAGENT || exit 5

start() {
	echo -n $"Starting $prog: "
        cd $Path
	/usr/local/smsagent/srmagent -f -c /usr/local/smsagent/snmpd.conf UDP:6569 &
	#touch /var/lock/subsys/srmagent
	rc_status -v
	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	cd /usr/local/smsagent/
	killall srmagent &> /dev/null
	/usr/local/smsagent/stopwatchdog
	RETVAL=$?
	#rm -f /var/lock/subsys/srmagent
	rc_status -v
	return $RETVAL
}

reload(){
	echo -n $"Reloading $prog: "
	stop
	start
}

restart(){
	stop
	start
}

condrestart(){
#    [ -e /var/lock/subsys/snmpd ] && restart
    return 0
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
        ;;
  reload)
	reload
        ;;
  condrestart)
	condrestart
	;;
  status)
#        status snmpd
	RETVAL=$?
        ;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
	RETVAL=1
esac

exit $RETVAL
