File syslog-ng.rc-script of Package syslog-ng
#! /bin/sh
# Copyright (c) 1995-2006 SUSE LINUX Products GmbH
#
# Author:
# Marius Tomaschewski <mt@suse.de>
#
# Sample init script to start an additional syslog-ng daemon.
#
# Should be installed as e.g. /etc/init.d/syslog-ng-user for
# a configuration file /etc/syslog-ng/syslog-ng-user.conf,
# where the 'user' suffix is configureable.
#
### BEGIN INIT INFO
# Provides: syslog-ng-user
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Description: Start additional system logging daemon
### END INIT INFO
#
# ==>> YOU MAY ADOPT the $syslog_ng_name <<==
# ==>> bellow AND above Provides variable!! <<==
#
if test "$0" != "${0//*syslog-ng-/}" ; then
# use suffix we've found in script name
syslog_ng_name="syslog-ng-${0//*syslog-ng-/}"
else
syslog_ng_name="syslog-ng-user"
fi
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
# check binary and config
syslogng=/sbin/syslog-ng
configng=/etc/syslog-ng/${syslog_ng_name}.conf
pid_file=/var/run/${syslog_ng_name}.pid
test -x "$syslogng" || {
echo "$syslogng not installed"
test "$1" == "stop" && exit 0 || exit 5
}
test -f "$configng" || {
echo "$configng not avaliable"
test "$1" == "stop" && exit 0 || exit 6
}
# SuSE LSB status shell functions from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num><num>
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
# rc_active <name> check if service <name> is ative
#
. /etc/rc.status || exit 1
# reset status of this service
rc_reset
case "$1" in
start)
if test -s $pid_file ; then
killproc -p $pid_file $syslogng 2> /dev/null
echo -n "Re-"
fi
echo -n "Starting ${syslog_ng_name} service"
startproc -p $pid_file $syslogng -p $pid_file $SYSLOG_NG_PARAMS
rc_status -v
;;
stop)
echo -n "Shutting down ${syslog_ng_name} service"
killproc -p $pid_file -TERM $syslogng 2>/dev/null
rc_status -v
;;
try-restart|condrestart)
## Stop the service and if this succeeds (i.e. the
## service was running before), start it again.
$0 status >/dev/null
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
rc_status
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
rc_status
;;
force-reload|reload)
## Signal the daemon to reload its config.
echo -n "Reload ${syslog_ng_name} service"
killproc -p $pid_file -HUP $syslogng
rc_status -v
;;
status)
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0. checkproc
## returns LSB compliant status values:
## 0 - service running
## 1 - service dead, but /var/run/ pid file exists
## 2 - service dead, but /var/lock/ lock file exists
## 3 - service not running
echo -n "Checking for ${syslog_ng_name} service: "
checkproc -p $pid_file $syslogng
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload,
## give out the argument which is required for a reload.
test $configng -nt $pid_file && echo reload
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|probe}"
exit 1
;;
esac
rc_exit