File snmptt.init-suse of Package snmptt

#!/bin/sh
#
# Copyright (c) 2011 SUSE Linux Products GmbH Nuernberg, Germany. All rights reserved.
#
# Author: Lars Vogdt
#
# /etc/init.d/snmptt
#
### BEGIN INIT INFO
# Provides:       snmptt
# Required-Start: $syslog $local_fs $remote_fs
# Should-Start:   $network snmptrapd
# Required-Stop:  $syslog $local_fs $remote_fs
# Should-Stop:    $network snmptrapd
# Default-Start:  2 3 5
# Default-Stop:   0 1 6
# Short-Description: SNMP Trap Translator Daemon
# Description:    SNMP Trap Handler for use with the Net-SNMP / UCD-SNMP snmptrapd program
### END INIT INFO

OPTIONS="--daemon"
SNMPTTBIN="/usr/sbin/snmptt"
SNMPTTINI="/etc/snmp/snmptt.ini"

test -x $SNMPTTBIN || { echo "$SNMPTTBIN not installed"; 
    if [ "$1" = "stop" ]; then exit 0;
    else exit 5; fi; }

test -r $SNMPTTINI || { echo "$SNMPTTINI not existing";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 6; fi; }

# Read config
. /etc/rc.status

# Reset status of this service
rc_reset 

case "$1" in
    start)
        echo -n "Starting snmptt "
        /sbin/startproc $SNMPTTBIN $OPTIONS --ini="$SNMPTTINI"
        rc_status -v
    ;;
    stop)
        echo -n "Shutting down snmptt "
        killproc $SNMPTTBIN
        rc_status -v
    ;;
    try-restart|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
    ;;
    restart)
        $0 stop
        $0 start
        rc_status
    ;;
    force-reload|reload)
        echo -n "Reload service snmptt"
        killproc -HUP $SNMPTTBIN
        rc_status -v
    ;;
    status)
        echo -n "Checking for snmptt "
	    checkproc $SNMPTTBIN
	    rc_status -v
    ;;
    probe)
        test "$SNMPTTINI" -nt /var/run/snmptt.pid && echo "reload"
    ;;
    *)
	    echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
	    exit 1
	;;
esac
rc_exit
openSUSE Build Service is sponsored by