#!/bin/sh

start() {
  echo -n "Starting rsyslog daemon: "
  start-stop-daemon -S -q -p /var/run/rsyslogd.pid --exec /usr/sbin/rsyslogd
  [ $? = 0 ] && echo "OK" || echo "FAIL"
}

stop() {
  echo -n "Stopping rsyslog daemon: "
  start-stop-daemon -K -q -p /var/run/rsyslogd.pid
  [ $? = 0 ] && echo "OK" || echo "FAIL"
}

restart() {
  stop
  sleep 1
  start
}

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

exit $?
