#!/bin/sh
#
# Autor: Ciro Iriarte <ciriarte@personal.com.py>
#
# /etc/init.d/snmptt
#
#   y el link simbolico
#
# /usr/sbin/rcsnmptt
#
# Script de inicio para snmptt
#
### BEGIN INIT INFO
# Provides: snmptt
# Required-Start: $remote_fs $syslog $network $snmptrapd
# Required-Stop:  $remote_fs $syslog
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Description:    snmptt, para integrar traps con el nagios
### END INIT INFO

. /etc/rc.status

OPTIONS="--daemon"
SNMPTTBIN="/usr/sbin/snmptt"
prog="snmptt"

test -x $NAGIOS_BIN || exit 5

rc_reset 

case "$1" in
  start)
	echo -n "Starting $prog: "
	startproc $SNMPTTBIN $OPTIONS
	rc_status -v
	;;
  stop)
	echo -n "Stopping $prog: "
	killproc -TERM $SNMPTTBIN
	rm -f /var/lock/subsys/snmptt
	rc_status -v
	;;
  restart)
	$0 stop
	$0 start
	rc_status
        ;;
  reload)
	echo -n "Reload service $prog "
	killproc -HUP $SNMPTTBIN
	rc_status -v
        ;;
  try-restart)
      ## Do a restart only if the service was active before.
      ## Note: try-restart is now part of LSB (as of 1.9).
      ## RH has a similar command named condrestart.
      $0 status
      if test $? = 0; then
              $0 restart
      else
              rc_reset        # Not running is not a failure.
      fi
      # Remember status and be quiet
      rc_status
      ;;

  status)
        echo -n "Checking for $prog "
	checkproc $SNMPTTBIN
	rc_status -v
        ;;
  *)
	echo "Usage: $0 {start|stop|status|try-restart|restart|reload}"
	exit 1
	;;
esac

rc_exit
