#!/bin/sh
#
# vm-pop3d	VirtualMail pop3d
#
# chkconfig: 	345 85 15
# description: 	vm-pop3d is a POP3 server with virtual domains support
# processname: 	pop3d

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

# Get network config
. /etc/sysconfig/network

# Check that networking is up.
if is_no "${NETWORKING}"; then
        # nls "ERROR: Networking is down. %s can't be run." <service>
        msg_Network_Down vm-pop3d
        exit 1
fi

# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
        if [ ! -f /var/lock/subsys/vm-pop3d ]; then
		msg_starting vm-pop3d
		daemon vm-pop3d -d 10 -t 600
	        RETVAL=$?
    		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/vm-pop3d
	else
        	msg_Already_Running vm-pop3d
	        exit 1
	fi
	;;
  stop)
        # Stop daemons.
	if [ -f /var/lock/subsys/vm-pop3d ]; then
                msg_stopping vm-pop3d
                killproc vm-pop3d
                rm -f /var/lock/subsys/vm-pop3d
        else
		msg_Not_Running vm-pop3d
	        exit 1
	fi
	;;
  status)
	status vm-pop3d
	exit $?
	;;
  restart|reload)
	$0 stop
	$0 start
	;;
  *)
	msg_Usage "$0 {start|stop|restart|status}"
	exit 1
	;;
esac

exit $RETVAL
