618683d
#! /bin/sh
618683d
#
618683d
# chkconfig: - 55 45
618683d
# description:	The memcached daemon is a network memory cache service.
618683d
# processname: memcached
618683d
# config: /etc/sysconfig/memcached
55b1212
# pidfile: /var/run/memcached/memcached.pid
618683d
618683d
# Standard LSB functions
888f13f
#. /lib/lsb/init-functions
618683d
618683d
# Source function library.
618683d
. /etc/init.d/functions
618683d
618683d
PORT=11211
55b1212
USER=memcached
618683d
MAXCONN=1024
618683d
CACHESIZE=64
618683d
OPTIONS=""
618683d
618683d
if [ -f /etc/sysconfig/memcached ];then 
618683d
	. /etc/sysconfig/memcached
618683d
fi
618683d
618683d
# Check that networking is up.
55b1212
. /etc/sysconfig/network
55b1212
618683d
if [ "$NETWORKING" = "no" ]
618683d
then
618683d
	exit 0
618683d
fi
618683d
618683d
RETVAL=0
618683d
prog="memcached"
618683d
618683d
start () {
618683d
	echo -n $"Starting $prog: "
618683d
	# insure that /var/run/memcached has proper permissions
55b1212
    if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
618683d
        chown $USER /var/run/memcached
55b1212
    fi
618683d
618683d
	daemon --pidfile /var/run/memcached/memcached.pid memcached -d -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached.pid $OPTIONS
618683d
	RETVAL=$?
618683d
	echo
618683d
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
618683d
}
618683d
stop () {
618683d
	echo -n $"Stopping $prog: "
618683d
	killproc -p /var/run/memcached/memcached.pid /usr/bin/memcached
618683d
	RETVAL=$?
618683d
	echo
618683d
	if [ $RETVAL -eq 0 ] ; then
618683d
	    rm -f /var/lock/subsys/memcached
618683d
	    rm -f /var/run/memcached.pid
618683d
	fi
618683d
}
618683d
618683d
restart () {
618683d
        stop
618683d
        start
618683d
}
618683d
618683d
618683d
# See how we were called.
618683d
case "$1" in
618683d
  start)
618683d
	start
618683d
	;;
618683d
  stop)
618683d
	stop
618683d
	;;
618683d
  status)
618683d
	status memcached
618683d
	;;
618683d
  restart|reload|force-reload)
618683d
	restart
618683d
	;;
618683d
  condrestart)
618683d
	[ -f /var/lock/subsys/memcached ] && restart || :
618683d
	;;
618683d
  *)
618683d
	echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
618683d
	exit 1
618683d
esac
618683d
618683d
exit $?