6a5d467
#!/bin/bash
6a5d467
#
6a5d467
# rsyslog        Starts rsyslogd/rklogd.
6a5d467
#
6a5d467
#
6a5d467
# chkconfig: 2345 12 88
6a5d467
# description: Syslog is the facility by which many daemons use to log \
6a5d467
# messages to various system log files.  It is a good idea to always \
6a5d467
# run rsyslog.
6a5d467
### BEGIN INIT INFO
6a5d467
# Provides: $syslog
6a5d467
# Required-Start: $local_fs
6a5d467
# Required-Stop: $local_fs
6a5d467
# Default-Start:  2 3 4 5
6a5d467
# Default-Stop: 0 1 6
6a5d467
# Short-Description: Enhanced system logging and kernel message trapping daemons
6a5d467
# Description: Rsyslog is an enhanced multi-threaded syslogd supporting, 
6a5d467
#              among others, MySQL, syslog/tcp, RFC 3195, permitted 
6a5d467
#              sender lists, filtering on any message part, and fine 
6a5d467
#              grain output format control.
6a5d467
### END INIT INFO
6a5d467
6a5d467
# Source function library.
6a5d467
. /etc/init.d/functions
6a5d467
6a5d467
RETVAL=0
daa6d9f
PIDFILE=/var/run/syslogd.pid
daa6d9f
daa6d9f
prog=rsyslogd
daa6d9f
exec=/sbin/rsyslogd
daa6d9f
lockfile=/var/lock/subsys/$prog
6a5d467
6a5d467
start() {
daa6d9f
	[ -x $exec ] || exit 5
6a5d467
6a5d467
	# Source config
6a5d467
        if [ -f /etc/sysconfig/rsyslog ] ; then
6a5d467
                . /etc/sysconfig/rsyslog
6a5d467
	fi
6a5d467
	umask 077
6a5d467
6a5d467
        echo -n $"Starting system logger: "
daa6d9f
        daemon --pidfile="${PIDFILE}" $exec $SYSLOGD_OPTIONS
6a5d467
        RETVAL=$?
6a5d467
        echo
daa6d9f
        [ $RETVAL -eq 0 ] && touch $lockfile
6a5d467
        return $RETVAL
6a5d467
}
6a5d467
stop() {
6a5d467
        echo -n $"Shutting down system logger: "
daa6d9f
        killproc $prog
6a5d467
        RETVAL=$?
6a5d467
        echo
daa6d9f
        [ $RETVAL -eq 0 ] && rm -f $lockfile
6a5d467
        return $RETVAL
6a5d467
}
6a5d467
reload()  {
6a5d467
    RETVAL=1
daa6d9f
    syslog=$(cat "${PIDFILE}" 2>/dev/null)
6a5d467
    echo -n "Reloading system logger..."
6a5d467
    if [ -n "${syslog}" ] && [ -e /proc/"${syslog}" ]; then
6a5d467
	kill -HUP "$syslog";
6a5d467
	RETVAL=$?
6a5d467
    fi
6a5d467
    if [ $RETVAL -ne 0 ]; then
6a5d467
	failure
6a5d467
    else
6a5d467
	success
6a5d467
    fi
6a5d467
    echo
6a5d467
    return $RETVAL
6a5d467
}
6a5d467
rhstatus() {
daa6d9f
        status -p "${PIDFILE}" $prog
6a5d467
}
6a5d467
restart() {
6a5d467
        stop
6a5d467
        start
6a5d467
}
6a5d467
6a5d467
case "$1" in
6a5d467
  start)
6a5d467
        start
6a5d467
        ;;
6a5d467
  stop)
6a5d467
        stop
6a5d467
        ;;
6a5d467
  restart)
6a5d467
        restart
6a5d467
        ;;
6a5d467
  reload|force-reload)
6a5d467
	reload
6a5d467
	;;
6a5d467
  status)
6a5d467
        rhstatus
6a5d467
        ;;
daa6d9f
  condrestart|try-restart)
daa6d9f
        rhstatus >/dev/null 2>&1 || exit 0
daa6d9f
        restart
6a5d467
        ;;
6a5d467
  *)
daa6d9f
        echo $"Usage: $0 {start|stop|restart|condrestart|try-restart|reload|force-reload|status}"
daa6d9f
        exit 3
6a5d467
esac
6a5d467
6a5d467
exit $?