Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > main-release-src > by-pkgid > 8fd95c1143e1ae0c5cd4e6ee0e7ea594 > files > 6

sysklogd-1.5-4mdv2010.0.src.rpm

#!/bin/sh
#
# sysklogd logging daemon
#
# chkconfig:    23457 12 88

### BEGIN INIT INFO
# Provides: $syslog
# Default-Start: 2 3 4 5 7
# Short-Description: System and kernel logging daemons
# Description: Syslog is the facility used by many daemons use to log messages.
### END INIT INFO

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

# Configuration variables
SYSLOGD_OPTIONS="-m 0"
KLOGD_OPTIONS="-x"
SYSLOG_UMASK=077
if [ -f /etc/sysconfig/syslog ] ; then
    . /etc/sysconfig/syslog
fi

# Other variables
NAME1="system logger"
NAME2="kernel logger"
LOCKFILE=/var/lock/subsys/syslog

umask $SYSLOG_UMASK

# [Pixel] shadow the initlog program
# => try to find the command when called as "initlog ...options... -c command args"
#    (hopefully the way to call initlog won't change!)
#
# why doing this: the pb of initlog being called when syslog is being
# restarted is that minilogd is started to keep the logs waiting for syslog to
# really treat them. Alas with devfs mounted (with or without devfsd),
# minilogd do not exit as it should. I don't know why.
#
# minilogd keeping the logs means its memory usage grows a lot as time goes.
# Restarting syslog mainly happens when upgrading glibc.
#
initlog() {
    while [ "$1" != "-c" ]; do
	[ -n "$1" ] || return
	shift
    done
    shift ; $*
}

start() {
    rc=0
    if [ ! -f $LOCKFILE ]; then
	echo -n "Starting $NAME1: "
	daemon syslogd $SYSLOGD_OPTIONS
	echo
	echo -n "Starting $NAME2: "
	daemon klogd $KLOGD_OPTIONS
	rc=$?
	echo
	[ $rc -eq 0 ] && touch $LOCKFILE
    fi
    return $rc
}

stop() {
    echo -n "Shutting down $NAME2: "
    killproc klogd
    echo
    echo -n "Shutting down $NAME1: "
    killproc syslogd
    rc=$?
    echo
    [ $rc -eq 0 ] && rm -f $LOCKFILE
    return $rc
}

restart() {
    stop
    start
}

reload()  {
    echo -n "Reloading down $NAME2: "
    killproc klogd -USR2
    echo
    echo -n "Reloading down $NAME1: "
    killproc syslogd -HUP
    rc=$?
    echo
    [ $rc -eq 0 ] && rm -f $LOCKFILE
    return $rc
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    restart)
	restart
	;;
    reload)
	reload
	;;
    condrestart)
    	if [ -f $LOCKFILE ]; then
	    restart
	fi
	;;
    status)
	status syslogd
	status klogd
	;;
    *)
	echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"
	exit 1
	;;
esac

exit $?