#!/bin/bash
#
# dc_server	This shell script takes care of starting and stopping dc_server.
#
# chkconfig: 2345 65 35
# description: dc_server - Distributed session cache server. \
# dc_server runs a cache server and starts listening on a \
# configurable network address for connections. Incoming \
# connections are expected to communicate using the distcache \
# protocol, and would typically be instances of dc_client \
# running on other machines.
# probe: false
# processname: dc_server
# pidfile: /var/run/dc_server.pid
# config: /etc/dc_server.conf

# 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/sbin/dc_server ] || exit 0

[ -f /etc/dc_server.conf ] || exit 0

# Source configuration.
. /etc/dc_server.conf

# See how we were called.
case "$1" in
start)
	gprintf "Starting dc_server: "
	dc_server -daemon -listen ${DC_LISTEN} \
	-sessions ${DC_SESSIONS} -pidfile /var/run/dc_server.pid
	success; echo
	touch /var/lock/subsys/dc_server
	;;
stop)
	gprintf "Stopping dc_server: "
	killproc dc_server
	echo
	rm -f /var/lock/subsys/dc_server
	;;
status)
	status dc_server
	;;
restart|reload)
	$0 stop
	$0 start
	;;
condrestart)
	[ -f /var/lock/subsys/dc_server ] && restart
	;;
  *)
	gprintf "Usage: dc_server {start|stop|status|restart|condrestart|reload}\n"
	exit 1
esac

exit 0
