#!/bin/bash
#
# memcached	This shell script takes care of starting and stopping memcached.
#
# chkconfig: 345 55 45
# description: memcached - high-performance memory object caching system.
# probe: false
# processname: memcached
# pidfile: /var/run/memcached.pid
# config: /etc/sysconfig/memcached

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

[ -f /etc/sysconfig/memcached ] && . /etc/sysconfig/memcached

# See how we were called.
case "$1" in
start)
	echo -n "Starting memcached: "
	daemon memcached -d ${MEMCACHED_OPTIONS:-""}
	echo
	touch /var/lock/subsys/memcached
	;;
stop)
	echo -n "Stopping memcached: "
	killproc memcached
	echo
	rm -f /var/lock/subsys/memcached
	;;
status)
	status memcached
	;;
restart|reload)
	$0 stop
	$0 start
	;;
condrestart)
	[ -f /var/lock/subsys/memcached ] && restart
	;;
  *)
	echo "Usage: memcached {start|stop|status|restart|condrestart|reload}"
	exit 1
esac

exit 0
