Pavol Rusnak 2010-03-09 14:25:50 +00:00 committed by Git OBS Bridge
parent c5f0e8fbe2
commit 20868ed526

View File

@ -2,19 +2,24 @@ Index: utils/redis_init_script
===================================================================
--- utils/redis_init_script.orig
+++ utils/redis_init_script
@@ -1,36 +1,67 @@
@@ -1,36 +1,64 @@
#!/bin/sh
+#
+# /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-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Redis server
+# Description: Manages the Redis server
+# Description: Starts and stops the Redis daemon
+### END INIT INFO
+
+. /etc/rc.status
REDISPORT=6379
-EXEC=/usr/local/bin/redis-server
@ -24,25 +29,19 @@ Index: utils/redis_init_script
-CONF="/etc/redis/${REDISPORT}.conf"
+PIDFILE=/var/run/redis.pid
+CONF=/etc/redis.conf
+
+. /etc/rc.status
+
+rc_reset
case "$1" in
start)
if [ -f $PIDFILE ]
then
- if [ -f $PIDFILE ]
- then
- echo -n "$PIDFILE exists, process is already running or crashed\n"
+ echo -n "$PIDFILE exists, process is already running or crashed"
+ rc_failed
else
- else
- echo -n "Starting Redis server...\n"
- $EXEC $CONF
+ echo -n "Starting Redis server..."
+ $EXEC $CONF > /dev/null
- fi
+ echo -n "Starting service Redis "
+ /sbin/startproc -p $PIDFILE -s -e $EXEC $CONF
+ rc_status -v
fi
;;
stop)
if [ ! -f $PIDFILE ]
@ -53,7 +52,7 @@ Index: utils/redis_init_script
else
- echo -n "Stopping ...\n"
- echo -n "SHUTDOWN\r\n" | nc localhost $REDISPORT &
+ echo -n "Stopping Redis server ..."
+ echo -n "Stopping service Redis ..."
+ echo -e "SHUTDOWN\r" | netcat localhost $REDISPORT &
PID=$(cat $PIDFILE)
while [ -x /proc/${PIDFILE} ]
@ -65,19 +64,21 @@ Index: utils/redis_init_script
- echo "Redis stopped"
fi
+ rc_status -v
;;
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ reload)
+ $0 restart
+ ;;
+ status)
+ if [ ! -f $PIDFILE ]
+ then
+ echo -n "Redis is not running"
+ else
+ echo -n "Redis is running"
+ fi
+ echo -n "Checking for service Redis: "
+ /sbin/checkproc -p $PIDFILE $EXEC
+ rc_status -v
+ ;;
;;
+ *)
+ echo "Usage: $0 [start|stop|status]"
+ ;;
+ echo $"Usage: $0 {start|stop|status|restart|reload}"
+ exit 1
esac
+
+rc_exit