syslogd 1.17 KB
Newer Older
1 2
#!/bin/sh

3 4 5 6 7 8 9 10 11 12 13 14 15
COUNTER_FILE="/tmp/start_cnt_syslogd"

start_counter() {
	# increase boot counter
	START_COUNTER=1
	if [ -f "$COUNTER_FILE" ];
	then
	    read -r START_COUNTER < $COUNTER_FILE
	    START_COUNTER=$((START_COUNTER+1))
	fi
	echo "$START_COUNTER" > $COUNTER_FILE
}

16 17 18 19
start() {
    # Check the configuration file: if there's no target, don't run the thing.
    if ! grep -q '^##.*remote-host' /etc/rsyslog.conf; then
	echo -n "Starting rsyslog: "
20 21 22 23 24 25 26 27 28 29 30
	start-stop-daemon -q -p /var/run/rsyslogd.pid -S \
		--exec /usr/sbin/rsyslogd
	ret=$?
	if [ $ret -eq 0 ]; then
	    start_counter
	    echo "OK"
	elif [ $ret -eq 1 ]; then
	    echo "Failed (already running?)"
	else
	    echo "Failed"
	fi
31 32
    else
	echo "Not starting rsyslog: no target host selected"
33 34
	# avoid SNMPd complaints about lack of start counter file
	echo "0" > $COUNTER_FILE
35 36 37 38
    fi
}

stop() {
39 40 41
    echo -n "Stopping rsyslog: "
    start-stop-daemon -K -q -p /var/run/rsyslogd.pid
    if [ $? -eq 0 ]; then
42
	echo "OK"
43 44
    else
	echo "Failed"
45 46
    fi
}
47

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
restart() {
    stop
    start
}

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart|reload)
  	restart
	;;
  *)
	echo $"Usage: $0 {start|stop|restart}"
	exit 1
	;;
esac