summaryrefslogtreecommitdiffstats
path: root/testing/redis/redis.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-06-04 12:49:51 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-06-04 12:52:59 +0000
commit728a7325eb258309ecc3213e5b7ec873cbe2e937 (patch)
tree7f1ebf2e7f90fbcd7de45b4736cc49579f0ae321 /testing/redis/redis.initd
parenta121333ef7dfcfe2a27fc85d787e26aae1c63df6 (diff)
downloadaports-728a7325eb258309ecc3213e5b7ec873cbe2e937.tar.bz2
aports-728a7325eb258309ecc3213e5b7ec873cbe2e937.tar.xz
testing/redis: various fixes
- avoid building linenoise at install time - set loglevel to 'notice' by default - set default log and pidfiles in redis subdir with permissions - create redis user at pre-install - fix init.d script to read pid, log and dir from redis.conf - remove unnneded vars from conf.d
Diffstat (limited to 'testing/redis/redis.initd')
-rwxr-xr-x[-rw-r--r--]testing/redis/redis.initd57
1 files changed, 34 insertions, 23 deletions
diff --git a/testing/redis/redis.initd b/testing/redis/redis.initd
index a23bcc774..3c4b7901c 100644..100755
--- a/testing/redis/redis.initd
+++ b/testing/redis/redis.initd
@@ -1,42 +1,53 @@
#!/sbin/runscript
-REDIS_EXEC=/usr/bin/redis-server
-REDIS_PID=${REDIS_PID:-/var/run/redis.pid}
-REDIS_DIR=${REDIS_DIR:-/var/lib/redis}
REDIS_CONF=${REDIS_CONF:-/etc/redis.conf}
-REDIS_OPTS=${REDIS_OPTS:-"${REDIS_CONF}"}
REDIS_USER=${REDIS_USER:-redis}
REDIS_GROUP=${REDIS_GROUP:-redis}
-REDIS_PORT=${REDIS_PORT:-6379}
-REDIS_CLIEXEC=/usr/bin/redis-cli
+
+name="Redis server"
+command=/usr/bin/redis-server
+command_args=${REDIS_CONF}
depend() {
use net localmount logger
after keepalived firewall
}
-start() {
+# get global pidfile, logfile, and dir from config file
+get_config() {
+ if [ ! -f "${REDIS_CONF}" ] ; then
+ eerror "You need a ${REDIS_CONF} file to run redis"
+ return 1;
+ fi
+
+ pidfile=$(awk '$1 == "pidfile" { print $2 }' "$REDIS_CONF")
+ logfile=$(awk '$1 == "logfile" { print $2 }' "$REDIS_CONF")
+ dir=$(awk '$1 == "dir" { print $2 }' "$REDIS_CONF")
+ : ${pidfile:=/var/run/redis/redis.pid}
+ : ${logfile:=/var/log/redis/redis.log}
+ : ${dir:=/var/lib/redis}
+}
- local PID_DIR=$(dirname ${REDIS_PID})
- checkpath -d -o ${REDIS_USER}:${REDIS_GROUP} ${PID_DIR}
+start() {
+ get_config || return 1
+ checkpath -d -o ${REDIS_USER}:${REDIS_GROUP} ${pidfile%/*} \
+ ${logfile%/*} ${dir}
- ebegin "Starting Redis server"
+ ebegin "Starting $name"
start-stop-daemon --start \
- --chdir "${REDIS_DIR}" \
+ --chdir "${dir}" \
--user ${REDIS_USER}:${REDIS_GROUP} \
- --pidfile "${REDIS_PID}" \
- --exec "${REDIS_EXEC}" \
- -- ${REDIS_OPTS}
- ret=$?
- eend ${ret}
-
+ --pidfile "${pidfile}" \
+ --exec "${command}" \
+ -- ${command_args}
+ eend $?
}
-stop() {
- ebegin "Stopping Redis server"
- start-stop-daemon --stop --quiet --pidfile "${REDIS_PID}"
- ret=$?
- rm -f "${REDIS_PID}"
- eend ${ret}
+stop_post() {
+ get_config
+ ebegin "Stopping $name"
+ start-stop-daemon --stop --quiet --pidfile "${pidfile}" \
+ && rm -f "${pidfile}"
+ eend $?
}