Skip to content

Instantly share code, notes, and snippets.

@thash
Forked from lsbardel/redis-server-for-init.d-startup
Created September 10, 2012 05:09
Show Gist options
  • Save thash/3688981 to your computer and use it in GitHub Desktop.
Save thash/3688981 to your computer and use it in GitHub Desktop.
Init.d Redis script for Fedora16
#!/bin/bash
#
# Init file for Redis server
#
# chkconfig: - 98 02
# description: Persistent key-value db
#
# processname: redis
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
# Short-Description: Persistent key-value db
# Source function library.
. /etc/init.d/functions
### Default variables
CONFIG="/etc/redis.conf"
prog="redis-server"
PATH=/usr/local/bin:$PATH
export PATH
# Check if requirements are met
[ -x /usr/local/bin/redis-server ] || exit 1
[ -r "$CONFIG" ] || exit 1
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon $prog $CONFIG
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}
stop() {
echo -n $"Shutting down $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
restart
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment