summaryrefslogtreecommitdiff
path: root/testing/memcached
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2012-08-18 00:02:28 +0000
committerroot <root@rshg054.dnsready.net>2012-08-18 00:02:28 +0000
commit948da5eabcbf8d74270e661d0730ba1c203913f5 (patch)
tree8536fd0b4622f9f6c77cb4716bf5c315c457038a /testing/memcached
parentbbf2c63849bdf1654e767058f277da2e983c5f0b (diff)
Sat Aug 18 00:02:28 UTC 2012
Diffstat (limited to 'testing/memcached')
-rw-r--r--testing/memcached/PKGBUILD38
-rw-r--r--testing/memcached/memcached.conf4
-rw-r--r--testing/memcached/memcached.install22
-rw-r--r--testing/memcached/memcached.service11
-rw-r--r--testing/memcached/memcached.sh63
5 files changed, 138 insertions, 0 deletions
diff --git a/testing/memcached/PKGBUILD b/testing/memcached/PKGBUILD
new file mode 100644
index 000000000..540073226
--- /dev/null
+++ b/testing/memcached/PKGBUILD
@@ -0,0 +1,38 @@
+# $Id: PKGBUILD 165366 2012-08-16 14:41:50Z dan $
+# Maintainer: Dan McGee <dan@archlinux.org>
+# Contributor: Michael Irwin <6d6469@gmail.com>
+
+pkgname=memcached
+pkgver=1.4.14
+pkgrel=2
+pkgdesc="A distributed memory object caching system"
+arch=(i686 x86_64)
+url="http://memcached.org/"
+license=('GPL')
+depends=('libevent')
+optdepends=('perl: for memcached-tool usage')
+backup=('etc/conf.d/memcached')
+install=memcached.install
+source=(http://memcached.googlecode.com/files/$pkgname-$pkgver.tar.gz
+ memcached.conf
+ memcached.sh
+ memcached.service)
+sha256sums=('f2e2ad8ee8d256f2c3748d7f741dcddfd0ab6bdece6fa1c18484e83f311156ef'
+ '17f66873b77e96c6706dcf13ab0aa8ddff94b2851366c787fc23e614dfc11f47'
+ '72efa639c5a39c7c14f07cc51731ebbf82299870d9cf31cf3aaa981bc084b4eb'
+ '453cad82bddb25fac43fd5cedc5702b9b6c6abaf7498e21445facf20f25f53a6')
+
+build() {
+ cd "$srcdir/$pkgname-$pkgver"
+ ./configure --prefix=/usr
+ make
+}
+
+package() {
+ cd "$srcdir/$pkgname-$pkgver"
+ make DESTDIR="$pkgdir" install
+ install -D -m 755 scripts/memcached-tool "$pkgdir"/usr/bin/memcached-tool
+ install -D -m 644 ../memcached.conf "$pkgdir"/etc/conf.d/memcached
+ install -D -m 755 ../memcached.sh "$pkgdir"/etc/rc.d/memcached
+ install -D -m 644 ../memcached.service "$pkgdir"/usr/lib/systemd/system/memcached.service
+}
diff --git a/testing/memcached/memcached.conf b/testing/memcached/memcached.conf
new file mode 100644
index 000000000..4415e1a55
--- /dev/null
+++ b/testing/memcached/memcached.conf
@@ -0,0 +1,4 @@
+# user to run memcached as; also used for pid file ownership
+MEMCACHED_USER="memcached"
+# see 'memcached -h' for available options
+MEMCACHED_ARGS="-l 127.0.0.1 -t 1"
diff --git a/testing/memcached/memcached.install b/testing/memcached/memcached.install
new file mode 100644
index 000000000..6009b713f
--- /dev/null
+++ b/testing/memcached/memcached.install
@@ -0,0 +1,22 @@
+post_install() {
+ if ! getent group memcached >/dev/null; then
+ groupadd --system memcached
+ fi
+ if ! getent passwd memcached >/dev/null; then
+ useradd --system -c 'memcached user' -g memcached -d / -s /bin/bash memcached
+ passwd -l memcached >/dev/null
+ fi
+}
+
+post_upgrade() {
+ post_install $1
+}
+
+post_remove() {
+ if getent passwd memcached >/dev/null; then
+ userdel memcached
+ fi
+ if getent group memcached >/dev/null; then
+ groupdel memcached
+ fi
+}
diff --git a/testing/memcached/memcached.service b/testing/memcached/memcached.service
new file mode 100644
index 000000000..c6e15fb7c
--- /dev/null
+++ b/testing/memcached/memcached.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Memcached Daemon
+After=network.target
+
+[Service]
+User=memcached
+# Remove '-l 127.0.0.1' to listen on all addresses
+ExecStart=/usr/bin/memcached -l 127.0.0.1
+
+[Install]
+WantedBy=multi-user.target
diff --git a/testing/memcached/memcached.sh b/testing/memcached/memcached.sh
new file mode 100644
index 000000000..9c9727507
--- /dev/null
+++ b/testing/memcached/memcached.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /etc/conf.d/memcached
+
+PIDFILE='/var/run/memcached.pid'
+
+getpid() {
+ local pid
+ pid=$(cat $PIDFILE 2>/dev/null)
+ # if the process is no longer valid, don't return it
+ if [ -n "$pid" ]; then
+ if ! ps -p $pid >/dev/null; then
+ rm -f $PIDFILE
+ pid=""
+ fi
+ fi
+ echo $pid
+}
+
+PID="$(getpid)"
+
+case "$1" in
+ start)
+ stat_busy "Starting memcached"
+ # memcached is retarded and doesn't write to the pidfile
+ # before it drops permissions
+ if [ -n "$PID" ]; then
+ stat_fail
+ elif [ -z "$MEMCACHED_USER" ]; then
+ echo "MEMCACHED_USER must be defined in /etc/conf.d/memcached"
+ stat_fail
+ else
+ touch $PIDFILE && chown $MEMCACHED_USER $PIDFILE
+ /usr/bin/memcached -d -P $PIDFILE -u $MEMCACHED_USER $MEMCACHED_ARGS
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon memcached
+ stat_done
+ fi
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping memcached"
+ [ ! -z "$PID" ] && kill $PID &> /dev/null
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ rm -f $PIDFILE
+ rm_daemon memcached
+ stat_done
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac