File rc.earlysyslog of Package syslogd.363

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

. /etc/sysconfig/syslog

BINDIR=/sbin

if type -t rc_readonlyroot > /dev/null 2>&1 && rc_readonlyroot ; then
    echo "Disabling early syslog on read-only root filesystem."
    exit 0
fi

# update $SYSLOG_DAEMON if not up-to-date
test -n "$SYSLOG_DAEMON" && \
test -x "${BINDIR}/$SYSLOG_DAEMON" || {
     for SYSLOG_DAEMON in rsyslogd syslog-ng syslogd ; do
         test -x "${BINDIR}/$SYSLOG_DAEMON" && break
     done
}

# set daemon dependent variables
case "$SYSLOG_DAEMON" in
    rsyslogd)
	syslog=rsyslogd
	config=/etc/rsyslog.early.conf
	;;
    syslog-ng)
	syslog=syslog-ng
	config=/etc/syslog-ng/syslog-ng.conf
	;;
    *)
	syslog=syslogd
	config=/etc/syslog.conf
	;;
esac
syslog_bin=${BINDIR}/$syslog
  klog_bin=${BINDIR}/klogd

# check config and programs
test -s ${config}	  || {
    echo 1>&2 "${config} does not exist"
    if test "$1" == "stop" ; then exit 0 ; else exit 6 ; fi
}
test -x ${syslog_bin} || {
    echo 1>&2 "${syslog_bin} is not installed"
    if test "$1" == "stop" ; then exit 0 ; else exit 5 ; fi
}
test -x ${klog_bin}   || {
    echo 1>&2 "${klog_bin} 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}
	;;
    *)
    	# in hope this works with the rsyslog.early.conf file
	# (hard to implement for rsyslog with its includes/if
	# statements)...
	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