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