#!/bin/sh
# POP3 Daemon
#
# chkconfig:	345 80 20
# description:	POP3 Daemon

# 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
	msg_Network_Down "POP3"
	exit 1
fi

# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/tpop3d ]; then
		msg_starting "tpop3d"
		daemon /usr/sbin/tpop3d -f /etc/tpop3d.conf
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/tpop3d
	else
		msg_Already_Running "tpop3d"
		exit 1
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/tpop3d ]; then
		msg_stopping "tpop3d"
		killproc tpop3d
		RETVAL=$?
		rm -f /var/lock/subsys/tpop3d
	else
		msg_not_running "tpop3d"
		exit 1
	fi
	;;
  restart|reload)
	$0 stop
	$0 start
	;;
  status)
	status tpop3d
	;;
  *)
	msg_Usage "$0 {start|stop|restart|reload|status}"
	exit 1
esac

exit $RETVAL
