#!/bin/sh
#
# sympa                 Mailing Lists Management System
#
# chkconfig:	345 95 05
# description: sympa is a powerfull mailing lists management system.
#

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

# Get network config
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/sympa ] && . /etc/sysconfig/sympa

# Check that networking is up.
if is_yes "${NETWORKING}"; then
        if [ ! -f /var/lock/subsys/network ]; then
                # nls "ERROR: Networking is down. %s can't be run." sympa
                msg_network_down sympa
                exit 1
        fi
else
        exit 0
fi

# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	for p in sympa archived bounced
	do
		if [ ! -f /var/lock/subsys/$p ]; then
			msg_starting $p
         		daemon $SYMPA_DIR/$p.pl $(eval echo "\$SYMPA_"$p"_OPT")
			RETVAL=$?
    			[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$p
		else
			msg_Already_Running $p
		fi
	done
	;;
  stop)
        # Stop daemons.
	for p in bounced archived sympa
	do 
		if [ -f /var/lock/subsys/$p ]; then
               		msg_stopping $p 
                	killproc $p.pl
                	rm -f /var/lock/subsys/$p > /dev/null 2>&1
        	else
			msg_Not_Running $p 
		fi
	done
	;;
  status)
  	for p in sympa archived bounced
	do
		status $p.pl
	done
	RETVAL=$?
	exit $RETVAL
	;;
  restart|reload)
	$0 stop
	$0 start
	;;
  *)
	msg_Usage "$0 {start|stop|restart|status}"
	exit 1
	;;
esac

exit $RETVAL

