#!/bin/sh
#
# Source function library.
. /etc/rc.d/init.d/functions

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

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

[ -f /usr/local/sbin/spasmd ] || exit 0

RETVAL=0

ulimit -n 8192
ulimit -s unlimited

# See how we were called.
case "$1" in
  start)
        echo -n "Starting spasm: "
        #daemon /usr/local/sbin/spasmd -p inet:9999
	daemon /usr/local/sbin/spasmd -p unix:/etc/mail/spasm/spasm.sock
        RETVAL=$?
        echo
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down spasm: "
        killproc spasmd -15
	rm -f /etc/mail/spasm/spasm.sock
        RETVAL=$?
        echo
        ;;
  restart|reload)
        $0 stop
        $0 start
        RETVAL=$?
        ;;
  *)
        echo "Usage: spasm {start|stop|restart}"
        exit 1
esac

exit $RETVAL
