#! /bin/sh
#
# Copyright (c) 1996-2001 SuSE GmbH Nuernberg, Germany.
# Copyright (c) 2002-2003 SuSE Linux AG, Nuernberg, Germany.
#
# Author: Florian La Roche <florian@suse.de>, 1996
#	  Werner Fink <werner@suse.de>, 1998-2001
#
# /etc/init.d/syslog
#
### BEGIN INIT INFO
# Provides:       earlysyslog
# Required-Start: 
# Required-Stop:  
# Default-Start:  5
# Default-Stop:
# Description:    Start the system logging daemons
### END INIT INFO

. /etc/sysconfig/syslog

BINDIR=/sbin

case "$SYSLOG_DAEMON" in
    syslog-ng)
	syslog=syslog-ng
	config=/etc/syslog-ng/syslog-ng.conf
	;;
    *)
	syslog=syslogd
	config=/etc/syslog.conf
	;;
esac

# check config and programs
test -s ${config}	  || {
    echo 1>&2 "${config} does not exists"
    if test "$1" == "stop" ; then exit 0 ; else exit 6 ; fi
}
test -x ${BINDIR}/$syslog || {
    echo 1>&2 "${BINDIR}/$syslog is not installed"
    if test "$1" == "stop" ; then exit 0 ; else exit 5 ; fi
}
test -x ${BINDIR}/klogd   || {
    echo 1>&2 "${BINDIR}/klogd is not installed"
    if test "$1" == "stop" ; then exit 0 ; else exit 5 ; fi
}

case "$SYSLOG_DAEMON" in
    syslog-ng)
	while read line ; do
	    case "$line" in
		\#*|"")	continue ;;
		*udp\ *|*udp\(*) exit 0 ;;
		*tcp\ *|*tcp\(*) exit 0 ;;
	    esac
	done < ${config}
	;;
    *)
	while read select action ; do
	    case "$select" in \#*|"") continue ;; esac
	    case "$action" in *@*)    exit 0   ;; esac
	done < ${config}
	;;
esac

exec /etc/init.d/syslog $1 early
