#!/sbin/openrc-run # $Id$ depend() { need net } checkconfig() { if [ -z "${LISTENON}" ]; then ewarn "You should edit /etc/conf.d/memcached and specify an address to listen on." ewarn "Listening on any address (I hope your firewall is set up properly)" fi } start() { ebegin "Starting memcached" checkconfig local dir="$(dirname ${PIDFILE})" if [ ! -d "${dir}" ]; then einfo " Creating ${dir}" mkdir -p "${dir}" fi chown ${MEMCACHED_RUNAS} "${dir}" if [ -f ${PIDFILE} ]; then einfo " Removing stale pidfile ${PIDFILE}" rm -f ${PIDFILE} 1>/dev/null fi if [ -z "${LISTENON}" ]; then c_LISTENON="" else c_LISTENON="-l ${LISTENON}" fi /sbin/start-stop-daemon --start --pidfile ${PIDFILE} \ --exec ${MEMCACHED_BINARY} -- \ -d -p ${PORT} ${c_LISTENON} -m ${MEMUSAGE} \ -c ${MAXCONN} -u ${MEMCACHED_RUNAS} -P ${PIDFILE} ${MISC_OPTS} eend $? } stop() { ebegin "Stopping memcached" start-stop-daemon --stop --quiet --pidfile ${PIDFILE} rm -f ${PIDFILE} eend $? }