#!/bin/sh
#
# klogd         Starts klogd.
#
# chkconfig:    2345 31 69
# description:	Klogd catches kernel messages and sends it to syslog daemon. \
#		It is a good idea to always run klogd.


# Source function library
. /etc/rc.d/init.d/functions

# Get network config
. /etc/sysconfig/network

# Set defaults        
CONSOLELOG_LEVEL=4

# Get service config
[ -f /etc/sysconfig/klogd ] && . /etc/sysconfig/klogd

if [ -n "$CONSOLELOG_LEVEL" ]; then
	OPTIONS="$OPTIONS -c $CONSOLELOG_LEVEL"
fi


# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/klogd ]; then
		msg_starting "Kernel logger"
		daemon klogd $OPTIONS
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/klogd
	else
		msg_already_running "Kernel logger"
		exit 1
	fi
	;;
    stop)	
	if [ -f /var/lock/subsys/klogd ]; then
		msg_stopping "Kernel logger"
		killproc klogd
		rm -f /var/lock/subsys/klogd >/dev/null 2>&1
	else
		msg_not_running "Kernel logger"
		exit 1
	fi	
	;;
  status)
	status klogd
	exit $?
	;;
  restart|reload)
	$0 stop
	$0 start
	;;
  *)
	msg_usage "$0 {start|stop|status|restart|reload}"
	exit 1
esac

exit $RETVAL
