File syslog-ng-ng2mysql.init of Package eventdb

#!/bin/sh
# Start/stop the syslog2mysql daemon.
#
# chkconfig: 345 99 01
# description: Icinga network monitor
### BEGIN INIT INFO
# Provides:          syslog-ng2mysql
# Required-Start:    $syslog $remote_fs
# Should-Start:      $time
# Required-Stop:     $syslog $remote_fs
# Should-Stop:       $time
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: EventDB syslog-ng2mysql Initscript
# Description:       EventDB Syslog to MySQL allows you to write 
#	data directly into the syslog-ng database.
### END INIT INFO

DAEMON='/usr/sbin/syslog-ng2mysql.pl'
test -x $DAEMON || { echo "$DAEMON not installed";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

PID='/var/run/syslog-ng2mysql.pid'
FIFO=$(cat $DAEMON |egrep -i '^my \$fifo' |cut -d"=" -f2 |sed 's/"//g; s/;//g')
test -p $FIFO || mkfifo $FIFO

# Shell functions sourced from /etc/rc.status
. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
start) echo -n "Starting syslog2mysql daemon "
	/sbin/startproc -p "$PID" $DAEMON
	rc_status -v
	;;
stop) echo -n "Shutting down syslog2mysql daemon "
	$DAEMON --stop --quiet --pidfile "$PID"
	/sbin/killproc -TERM $DAEMON
	rc_status -v
	;;
try-restart|condrestart)
	## 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.
	if test "$1" = "condrestart"; then
		echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
	fi
	$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
	;;
reload)
	echo -n "Reloading service syslog2mysql "
	rc_failed 3
	rc_status -v
	;;
restart)
	$0 stop
	$0 start
	rc_status
	;;
status)
	echo -n "Checking for service syslog2mysql "
	/sbin/checkproc $DAEMON
	rc_status -v
	;;
*) echo "Usage: $0 {start|stop|status|reload|try-restart|restart}"
	exit 1
	;;
esac
rc_exit
openSUSE Build Service is sponsored by