#!/bin/sh
#
# $Id: init.d.solaris,v 1.3 2003/04/11 13:37:47 bazsi Exp $
#
# adapted to syslog-ng by BJ, Aug, 7th 2000
# cleaned up by Bazsi, Oct, 12th 2000
# minor fix by Bojan Zdrnja, Apr, 11th 2003
#   added nicer options field
#

DAEMON=/usr/local/sbin/syslog-ng
OPTIONS="-f /etc/syslog-ng/syslog-ng.conf"

case "$1" in
	start)
	        if [ -f /etc/syslog-ng/syslog-ng.conf -a -f /usr/local/sbin/syslog-ng ]; then
	                echo 'syslog-ng service starting.'
	                #
	                # Before syslog-ng starts, save any messages from previous
	                # crash dumps so that messages appear in chronological order.
	                #
	                /usr/bin/savecore -m
	                if [ -r /etc/dumpadm.conf ]; then
	                        . /etc/dumpadm.conf
	                        [ "x$DUMPADM_DEVICE" != xswap ] && \
	                            /usr/bin/savecore -m -f $DUMPADM_DEVICE
	                fi
	                $DAEMON $OPTIONS -p /etc/syslog-ng/syslog-ng.pid
	        fi
        	;;

	stop)
	        if [ -f /etc/syslog-ng/syslog-ng.pid ]; then
	                syspid=`/usr/bin/cat /etc/syslog-ng/syslog-ng.pid`
	                [ "$syspid" -gt 0 ] && kill -15 $syspid && rm /etc/syslog-ng/syslog-ng.pid
	        fi
        	;;
	*)
	        echo "Usage: $0 { start | stop }"
	        exit 1
        	;;
esac
