#! /bin/sh
#
# Copyright (c) 2002 SuSE Linux AG, Nuernberg, Germany. All rights reserved.
#
# /etc/init.d/boot.klog
#
### BEGIN INIT INFO
# Provides:          boot.klog
# Required-Start:    boot.localfs
# Required-Stop:
# Default-Start:     B
# Default-Stop:
# Description:       dump kernel messages
### END INIT INFO

. /etc/rc.status
. /etc/sysconfig/boot

rc_reset

case "$1" in
  start)
    # Read all kernel messages generated until now and put them in one file.
    test -s /var/log/boot.msg && mv -f /var/log/boot.msg /var/log/boot.omsg
    if test -x /sbin/klogd ; then
	echo Creating /var/log/boot.msg
	/sbin/klogd -s -o -n -f /var/log/boot.msg
	/bin/sync
	test -s /var/log/boot.msg
	rc_status -v1 -r
    elif test -x /bin/dmesg ; then
	echo Creating /var/log/boot.msg
	/bin/dmesg -s16384 > /var/log/boot.msg
	/bin/sync
	test -s /var/log/boot.msg
	rc_status -v1 -r
    fi
    if test -x /usr/sbin/klogconsole ; then
	if test -x /sbin/showconsole ; then
		if test "`/sbin/showconsole`" = /dev/tty1 ; then
		    ( test -c /dev/tty10 && > /dev/tty10 ) > /dev/null 2>&1 \
			&& /usr/sbin/klogconsole $KLOGCONSOLE_PARAMS -r10 
		else
		    /usr/sbin/klogconsole $KLOGCONSOLE_PARAMS -r 0
		fi
	fi
    elif test -x /bin/dmesg ; then
	/bin/dmesg -n 7
    fi
    #
    # Say blogd that I/O is possible now
    #
    test -x /sbin/blogd && killproc -IO /sbin/blogd
   ;;
  stop|restart)
    # skip / nothing to do
    ;;
  status)
    rc_failed 4
    rc_status -v
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart}"
    exit 1
    ;;
esac

rc_exit

