aboutsummaryrefslogtreecommitdiffstats
path: root/main/memcached/memcached.initd
diff options
context:
space:
mode:
authorCarlo Landmeter <clandmeter@gmail.com>2011-04-13 10:37:05 +0000
committerCarlo Landmeter <clandmeter@gmail.com>2011-04-13 10:37:05 +0000
commitd799936de683061e7c04c2fb34a6541d2fb2a6c4 (patch)
treeb0c95bac3229ad3ff54cae7658bd569f97e2b590 /main/memcached/memcached.initd
parent8728a1db8aad5cfec5228f65921fb4d777956037 (diff)
downloadaports-d799936de683061e7c04c2fb34a6541d2fb2a6c4.tar.bz2
aports-d799936de683061e7c04c2fb34a6541d2fb2a6c4.tar.xz
main/memcached: moved from testing to main
Diffstat (limited to 'main/memcached/memcached.initd')
-rw-r--r--main/memcached/memcached.initd80
1 files changed, 80 insertions, 0 deletions
diff --git a/main/memcached/memcached.initd b/main/memcached/memcached.initd
new file mode 100644
index 0000000000..74b2c60918
--- /dev/null
+++ b/main/memcached/memcached.initd
@@ -0,0 +1,80 @@
+#!/sbin/runscript
+# $Header: /var/cvsroot/gentoo-x86/net-misc/memcached/files/1.3.3/init,v 1.1 2009/05/26 00:03:09 robbat2 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
+ # per bug #269022, accurate time is important for memcached!
+ # We include the full list of ways it might be set on boot.
+ after ntp-client ntpd rdate openrdate adjtimex hwclock
+}
+
+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} -U ${UDPPORT} ${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 $?
+}