#! /bin/sh
# /etc/init.d/klogd: start the kernel log daemon.

### BEGIN INIT INFO
# Provides:             klogd
# Required-Start:       $syslog
# Required-Stop:        $syslog
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Kernel logger
### END INIT INFO

PATH=/bin:/usr/bin:/sbin:/usr/sbin

pidfile=/var/run/klogd.pid
binpath=/sbin/klogd

test -f $binpath || exit 0

test ! -r /etc/default/klogd || . /etc/default/klogd

. /lib/lsb/init-functions

case "$1" in
  start)
    log_begin_msg "Starting kernel log daemon..."
    start-stop-daemon --start --quiet --pidfile $pidfile --name klogd --startas $binpath -- $KLOGD
    log_end_msg $?
    test -d /lib/init/rw/sendsigs.omit.d || mkdir -p /lib/init/rw/sendsigs.omit.d
    test ! -f /lib/init/rw/sendsigs.omit.d/klogd || rm -f /lib/init/rw/sendsigs.omit.d/klogd
    ln -s $pidfile /lib/init/rw/sendsigs.omit.d/klogd
    ;;
  stop)
    log_begin_msg "Stopping kernel log daemon..."
    start-stop-daemon --stop --quiet --retry 3 --exec $binpath --pidfile $pidfile
    log_end_msg $?
    ;;
  restart|force-reload)
    log_begin_msg "Reloading kernel log daemon..."
    start-stop-daemon --stop --quiet --retry 3 --exec $binpath --pidfile $pidfile
    start-stop-daemon --start --quiet --pidfile $pidfile --name klogd --startas $binpath -- $KLOGD
    log_end_msg $?
    ;;
  *)
    log_success_msg "Usage: /etc/init.d/klogd {start|stop|restart|force-reload}"
    exit 1
esac

exit 0
