diff options
Diffstat (limited to 'net-misc/memcached/files/1.2.6/init')
-rw-r--r-- | net-misc/memcached/files/1.2.6/init | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/net-misc/memcached/files/1.2.6/init b/net-misc/memcached/files/1.2.6/init new file mode 100644 index 000000000000..e4efc5a09cd4 --- /dev/null +++ b/net-misc/memcached/files/1.2.6/init @@ -0,0 +1,77 @@ +#!/sbin/runscript +# $Header: /var/cvsroot/gentoo-x86/net-misc/memcached/files/1.2.6/init,v 1.1 2008/08/01 15:56:55 caleb Exp $ + +CONF="${SVCNAME#*.}" +CONFBASE="/etc/conf.d/memcached" + +[ -z "${PIDBASE}" ] && PIDBASE="/var/run/memcached/memcached" +[ "${CONF}" == "memcached" ] && CONF='' + +if [ -n "${CONF}" ]; then + PIDFILE="${PIDBASE}-${PORT}.${CONF}.pid" + CONFSRC="${CONFBASE}.${CONF}" + if [ -f "${CONFSRC}" ]; then + source "${CONFSRC}" + else + eerror "The configuration file $CONFSRC was not found!" + fi +else + PIDFILE="${PIDBASE}-${PORT}.pid" + CONFSRC="${CONFBASE}" +fi + +depend() { + need net +} + +checkconfig() { + if [ -z "${LISTENON}" ]; then + ewarn "You should edit $CONFSRC and specify an address to listen on." + ewarn "Listening on any address (check your firewall!)" + fi + +} + +start() { + if [ -n "${CONF}" ]; then + ebegin "Starting memcached (${CONF})" + else + ebegin "Starting memcached" + fi + 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}" \ + --startas "${MEMCACHED_BINARY}" -- \ + -d -p ${PORT} ${c_LISTENON} -m ${MEMUSAGE} \ + -c ${MAXCONN} -u ${MEMCACHED_RUNAS} -P "${PIDFILE}" \ + ${MISC_OPTS} + eend $? +} + +stop() { + if [ -n "${CONF}" ]; then + ebegin "Stopping memcached (${CONF})" + else + ebegin "Stopping memcached" + fi + start-stop-daemon --stop --quiet --pidfile "${PIDFILE}" + rm -f "${PIDFILE}" + eend $? +} |