#!/bin/bash
#
# Messagewall startup script written by Gauret <aurelienb@netcourrier.com>
# Uses Syslog : facility "local1", level "info". You need to add the following
# line to your /etc/syslog.conf :
# local1.*		/var/log/mail/messagewall.log
# or adapt the script if you already use local1
#
# see also the messagewall.logrotate to rotate your logs

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


# Source networking configuration.
. /etc/sysconfig/network

PATH=/usr/bin:/sbin:/bin:/usr/sbin:/usr/local/bin
export PATH

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# start function
startmw() {
    echo -n "Starting MessageWall...       "
# Change "local1.info" to the syslog level you want.
    /usr/local/bin/messagewall 2>&1 | /usr/bin/logger -t Messagewall -p local1.info &
    echo "[ OK ]"
}

# stop function
stopmw() {
    echo -n "Halting MessageWall...       "
    messagewallctl stop
    echo "[ OK ]"
}


case "$1" in
start)
    startmw
    ;;

stop)
    stopmw
    ;;

restart)
    stopmw
    startmw
    ;;

status)
    status messagewall
    ;;

stats)
    messagewallstats /var/log/mail/messagewall.log
    ;;

*)
    echo "Usage: $0 {start|stop|status|restart|stats}"
    exit 1
esac

exit 0
