Accepting request 142127 from server:database

Hi,

the basename "-s" option is not available on OpenSUSE 11's coreutils. 

I have changed the initscript to use the historical basename NAME [SUFFIX] syntax, that works on both 11 and 12.

Thanks!

~Marcello (forwarded request 142125 from vjt)

OBS-URL: https://build.opensuse.org/request/show/142127
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/redis?expand=0&rev=6
This commit is contained in:
Stephan Kulow 2012-11-21 16:20:38 +00:00 committed by Git OBS Bridge
commit 64ecdce7d7
4 changed files with 186 additions and 82 deletions

View File

@ -1,12 +1,6 @@
---
redis.conf | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
Index: redis.conf
===================================================================
--- redis.conf.orig 2011-10-17 10:46:00.000000000 +0200
+++ redis.conf 2011-10-24 12:47:49.839930573 +0200
@@ -14,7 +14,7 @@
--- redis.conf.orig 2012-07-31 16:56:02.000000000 +0200
+++ redis.conf 2012-07-31 16:59:31.000000000 +0200
@@ -14,11 +14,11 @@
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
@ -15,7 +9,12 @@ Index: redis.conf
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
@@ -27,7 +27,7 @@ port 6379
-pidfile /var/run/redis.pid
+pidfile /var/run/redis/default.pid
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
@@ -27,7 +27,7 @@
# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
#
@ -24,7 +23,7 @@ Index: redis.conf
# Specify the path for the unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
@@ -45,12 +45,12 @@ timeout 300
@@ -45,12 +45,12 @@
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
@ -35,16 +34,25 @@ Index: redis.conf
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
-logfile stdout
+logfile /var/log/redis/redis.log
+logfile /var/log/redis/default.log
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
@@ -104,7 +104,7 @@ dbfilename dump.rdb
@@ -104,7 +104,7 @@
# Also the Append Only File will be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
-dir ./
+dir /var/lib/redis/
+dir /var/lib/redis/default/
################################# REPLICATION #################################
@@ -386,7 +386,7 @@
# *** WARNING *** if you are using a shared hosting the default of putting
# the swap file under /tmp is not secure. Create a dir with access granted
# only to Redis user and configure Redis to create the swap file there.
-vm-swap-file /tmp/redis.swap
+vm-swap-file /var/lib/redis/default/redis.swap
# vm-max-memory configures the VM to use at max the specified amount of
# RAM. Everything that deos not fit will be swapped on disk *if* possible, that

View File

@ -1,39 +1,120 @@
Index: utils/redis_init_script
===================================================================
--- utils/redis_init_script.orig 2011-10-17 10:46:00.000000000 +0200
+++ utils/redis_init_script 2011-10-24 12:47:43.108960720 +0200
@@ -1,42 +1,75 @@
--- utils/redis_init_script.orig 2012-07-31 16:48:33.000000000 +0200
+++ utils/redis_init_script 2012-11-20 15:05:55.000000000 +0100
@@ -1,42 +1,131 @@
#!/bin/sh
+
+# System startup script for Redis for OpenSUSE >= 11.4
+#
+# Author: Marcello Barnaba <m.barnaba@ifad.org>
+# Tue Jul 31 17:32:27 CEST 2012
+#
+# LSB-compatible service control script; see http://www.linuxbase.org/spec/
+# Install it in /etc/init.d/redis and run insserv /etc/init.d/redis
+# Define configurations in /etc/init.d/redis/NAME.conf
+#
+# Source: https://gist.github.com/804026
#
-# Simple Redis init.d script conceived to work on Linux systems
-# as it does use of the /proc filesystem.
+# /etc/init.d/redis
+#
+### BEGIN INIT INFO
+# Provides: redis
+# Required-Start: $syslog $remote_fs
+# Should-Start:
+# Required-Stop: $syslog $remote_fs
+# Should-Stop:
+# Default-Start: 3 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Redis server
+# Description: Starts and stops the Redis daemon
+# Description: Starts and stops the configured Redis instances
+### END INIT INFO
+
+EXEC=/usr/sbin/redis-server
+USER=redis
+STATE=/var/run/redis
+CONF=/etc/redis
+
+. /etc/rc.status
+
+if [ ! -d $STATE ]; then
+ install -d $state -o $USER -g $USER -m 0755 $STATE
+fi
+
+_get_env() {
+ INSTANCE=$1
+ PIDFILE=${STATE}/${INSTANCE}.pid
+ CONFIG=${CONF}/${INSTANCE}.conf
+}
+
+_foreach_config() {
+ command=$1
+
+ if [ -n "$2" ]; then
+ $command $2
+ else
+ for file in /etc/redis/*.conf; do
+ $command `basename "$file" .conf`
+ done
+ fi
+}
+
+start() {
+ _get_env $1
+
+ echo -n "Starting Redis server '${INSTANCE}'... "
+
+ if [ ! -f ${CONFIG} ]; then
+ echo "$CONFIG not found"
+ rc_failed
REDISPORT=6379
-REDISPORT=6379
-EXEC=/usr/local/bin/redis-server
-CLIEXEC=/usr/local/bin/redis-cli
+EXEC=/usr/sbin/redis-server
+CLIEXEC=/usr/bin/redis-cli
+ elif [ -f ${PIDFILE} ] && [ -x /proc/`cat ${PIDFILE}` ]; then
+ echo -n "already running (PID `cat ${PIDFILE}`)"
+
+ else
+ rm -f ${PIDFILE}
+ sudo -u $USER $EXEC $CONFIG
+ fi
+ rc_status -v
+}
+
+stop() {
+ _get_env $1
+
+ echo -n "Stopping Redis server '${INSTANCE}' ... "
+
+ if [ ! -f $PIDFILE ]; then
+ echo -n "not running"
+ else
+ PID=`cat $PIDFILE`
+ CLI='/usr/bin/redis-cli'
+ PASS=`grep ^requirepass $CONFIG | awk '{print $2}'`
+ PORT=`grep ^port $CONFIG | awk '{print $2}'`
+
+ CLI="$CLI -p $PORT"
+ [ -n "$PASS" ] && CLI="$CLI -a $PASS"
+
+ $CLI shutdown
+ echo -n "Waiting... "
+
+ while [ -x /proc/${PID} ]; do
+ sleep 1
+ echo -n '.'
+ done
+ rm -f ${PIDFILE}
+ fi
+ rc_status -v
+}
+
+status() {
+ _get_env $1
+
+ echo -n "Checking for redis '${INSTANCE}'"
+ /sbin/checkproc -p $PIDFILE $EXEC
+ rc_status -v
+}
-PIDFILE=/var/run/redis_${REDISPORT}.pid
-CONF="/etc/redis/${REDISPORT}.conf"
+CONF=/etc/redis.conf
+PIDFILE=/var/run/redis.pid
+LOGFILE=/var/log/redis/redis.log
case "$1" in
start)
@ -43,58 +124,43 @@ Index: utils/redis_init_script
- else
- echo "Starting Redis server..."
- $EXEC $CONF
+ if [ ! -r $LOGFILE ]; then
+ touch $LOGFILE
+ chown redis:redis $LOGFILE
+ fi
+ # Create a pidfile the server can write into.
+ if [ ! -r $PIDFILE ]; then
+ touch $PIDFILE
+ chown redis:redis $PIDFILE
fi
+ echo -n "Starting service Redis "
+ /sbin/startproc -u redis -g redis -p $PIDFILE -s -e $EXEC $CONF >/dev/null 2>&1
+ rc_status -v
;;
- fi
- ;;
+ _foreach_config start $2
+ ;;
+
stop)
if [ ! -f $PIDFILE ]
then
- if [ ! -f $PIDFILE ]
- then
- echo "$PIDFILE does not exist, process is not running"
+ echo -n "$PIDFILE does not exist, process is not running"
+ rc_failed
else
- else
- PID=$(cat $PIDFILE)
- echo "Stopping ..."
+ echo -n "Stopping service Redis..."
$CLIEXEC -p $REDISPORT shutdown
- $CLIEXEC -p $REDISPORT shutdown
- while [ -x /proc/${PID} ]
+ PID=$(cat $PIDFILE)
+ while [ -x /proc/${PIDFILE} ]
do
- do
- echo "Waiting for Redis to shutdown ..."
sleep 1
done
- sleep 1
- done
- echo "Redis stopped"
fi
+ rc_status -v
;;
- *)
- echo "Please use start or stop as first argument"
+ restart)
+ $0 stop
+ $0 start
;;
+ reload)
+ $0 restart
+ ;;
+ status)
+ echo -n "Checking for service Redis: "
+ /sbin/checkproc -p $PIDFILE $EXEC
+ rc_status -v
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|reload}"
+ exit 1
esac
+rc_exit
- fi
- ;;
+ _foreach_config stop $2
+ ;;
+
+ status)
+ _foreach_config status $2
+ ;;
+
+ restart)
+ $0 stop $2
+ $0 start $2
+ ;;
+
*)
- echo "Please use start or stop as first argument"
- ;;
+ echo "Usage: $0 <start|stop|restart|status>"
+ exit 1
+ ;;
esac

View File

@ -1,3 +1,26 @@
-------------------------------------------------------------------
Tue Nov 20 07:40:52 UTC 2012 - dimstar@opensuse.org
- Fix useradd invocation: -o is useless without -u and newer
versions of pwdutils/shadowutils fail on this now.
-------------------------------------------------------------------
Thu Nov 8 16:12:21 UTC 2012 - vjt@openssl.it
- Implement a multi-instance setup
* Allow for multiple configuration files of named instances
under /etc/redis
* Each instance has its own data directory
under /var/lib/redis/$INSTANCE
* Each instance has its own PID file
under /var/run/redis/$INSTANCE.pid
* Each instance has its own log files
under /var/log/redis/$INSTANCE.log
* Instances may be started or stopped individually passing a
second argument to the init script
* Do not create an active default.conf, rather use an
.example suffix
-------------------------------------------------------------------
Mon Jul 23 18:11:50 UTC 2012 - mrueckert@suse.de

View File

@ -18,6 +18,7 @@
%define _data_dir %{_localstatedir}/lib/%{name}
%define _log_dir %{_localstatedir}/log/%{name}
%define _conf_dir %{_sysconfdir}/%{name}
Name: redis
Version: 2.4.15
@ -68,14 +69,16 @@ different kind of sorting abilities.
make %{?_smp_mflags} CFLAGS="%{optflags}" V=1
%install
install -d %{buildroot}%{_log_dir} %{buildroot}%{_data_dir}
install -d %{buildroot}%{_log_dir} %{buildroot}%{_data_dir} %{buildroot}%{_conf_dir}
install -d %{buildroot}%{_log_dir}/default %{buildroot}%{_data_dir}/default
install -D -m 0755 src/redis-benchmark %{buildroot}%{_bindir}/redis-benchmark
install -m 0755 src/redis-cli %{buildroot}%{_bindir}/redis-cli
install -m 0755 src/redis-check-dump %{buildroot}%{_bindir}/redis-check-dump
install -m 0755 src/redis-check-aof %{buildroot}%{_bindir}/redis-check-aof
install -D -m 0755 src/redis-server %{buildroot}%{_sbindir}/redis-server
install -D -m 0640 redis.conf %{buildroot}%{_sysconfdir}/redis.conf
install -D -m 0640 redis.conf %{buildroot}%{_conf_dir}/default.conf.example
## install -Dp -m 0755 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/redis
#
@ -102,12 +105,14 @@ make test && true
%pre
/usr/sbin/groupadd -r %{name} &>/dev/null || :
/usr/sbin/useradd -o -g %{name} -s /bin/false -r -c "User for Redis key-value store" -d %{_data_dir} %{name} &>/dev/null || :
/usr/sbin/useradd -g %{name} -s /bin/false -r -c "User for Redis key-value store" -d %{_data_dir} %{name} &>/dev/null || :
%post
%fillup_and_insserv %{name}
%restart_on_update %{name}
echo "To start the database server, do:"
echo "To start the database server, create your configuration"
echo "starting from /etc/redis/default.conf.example, place it"
echo "in /etc/redis and do: "
echo " sudo rcredis start; sudo insserv redis"
%preun
@ -125,8 +130,10 @@ echo " sudo rcredis start; sudo insserv redis"
%{_sbindir}/redis-*
%{_sbindir}/rc%{name}
%config(noreplace) %{_sysconfdir}/init.d/redis
%config(noreplace) %attr(0640, %{name}, %{name}) %{_sysconfdir}/redis.conf
%config(noreplace) %attr(0640, %{name}, %{name}) %{_conf_dir}/default.conf.example
%dir %attr(0750, %{name}, %{name}) %{_data_dir}
%dir %attr(0750, %{name}, %{name}) %{_data_dir}/default
%dir %attr(0750, %{name}, %{name}) %{_log_dir}
%dir %attr(0750, %{name}, %{name}) %{_conf_dir}
%changelog