#!/bin/SH# Chkconfig:2345 - Ten# # # BEGIN INIT info# Provides:redis-server# Required-start: $network $remote _fs $syslog $ Time# Required-Stop: $network # Default-start:2 3 4 5# Default-stop:0 1 6# Short-description:start/stop redis-server### END INIT info## Simple Redis INIT.D script conceived to work on Linux systems# as it does use of the/proc FileSystem. Redisport=6379EXEC=/usr/local/bin/redis-servercliexec=/usr/local/bin/redis-Clipidfile=/var/run/redis_${redisport}.pidconf="/etc/redis/${redisport}.conf" Case " $" inchstart)if[ -F $PIDFILE] Then Echo "$PIDFILE exists, process is already running or crashed" Else Echo "starting Redis_$redisport Server ..."$EXEC $CONFfi ;; Stop)if[ ! -F $PIDFILE] Then Echo "$PIDFILE does not exist, process was not running" ElsePID=$(Cat$PIDFILE)Echo "stopping ..."<%if@password = ='NoPass'-%>$CLIEXEC-p $REDISPORT shutdown<%Else-%>$CLIEXEC-P $REDISPORT-a <%= @password%>shutdown<% End-%> while[-x/proc/${pid}] Do Echo "waiting for Redis_$redisport to shutdown ..." Sleep 2 Done Echo "Redis_$redisport stopped" fi ;; Status) PID=$(Cat$PIDFILE)if[ -F $PIDFILE] Then if[!-x/proc/${pid}] Then Echo 'Redis_$redisport is not running' RM-RF $PIDFILE Exit1 Else Echo "Redis_$redisport is running" fi Else Echo 'No PID File,redis_$redisport is not running'Exit1 fi ;; Restart) $0Stop $0start;; *) Echo "Please use start, stop, restart or status as first argument" ;;Esac
Ubuntu Redis Self-boot configuration file