af41006
#!/bin/sh
af41006
#
af41006
# redis        init file for starting up the redis-sentinel daemon
af41006
#
af41006
# chkconfig:   - 21 79
af41006
# description: Starts and stops the redis-sentinel daemon.
1968d3b
#
1968d3b
### BEGIN INIT INFO
1968d3b
# Provides: redis-sentinel
1968d3b
# Required-Start: $local_fs $remote_fs $network
1968d3b
# Required-Stop: $local_fs $remote_fs $network
1968d3b
# Short-Description: start and stop Sentinel server
1968d3b
# Description: A persistent key-value database
1968d3b
### END INIT INFO
af41006
af41006
# Source function library.
af41006
. /etc/rc.d/init.d/functions
af41006
f312977
name="redis-sentinel"
f312977
exec="/usr/bin/$name"
83364f0
shut="/usr/libexec/redis-shutdown"
f312977
pidfile="/var/run/redis/sentinel.pid"
af41006
SENTINEL_CONFIG="/etc/redis-sentinel.conf"
af41006
af41006
[ -e /etc/sysconfig/redis-sentinel ] && . /etc/sysconfig/redis-sentinel
af41006
af41006
lockfile=/var/lock/subsys/redis
af41006
af41006
start() {
af41006
    [ -f $SENTINEL_CONFIG ] || exit 6
f312977
    [ -x $exec ] || exit 5
f312977
    echo -n $"Starting $name: "
f312977
    daemon --user ${REDIS_USER-redis} "$exec $SENTINEL_CONFIG --daemonize yes --pidfile $pidfile"
af41006
    retval=$?
af41006
    echo
af41006
    [ $retval -eq 0 ] && touch $lockfile
af41006
    return $retval
af41006
}
af41006
af41006
stop() {
f312977
    echo -n $"Stopping $name: "
f312977
    [ -x $shut ] && $shut $name
af41006
    retval=$?
f312977
    if [ -f $pidfile ]
f312977
    then
f312977
        # shutdown haven't work, try old way
f312977
        killproc -p $pidfile $name
f312977
        retval=$?
f312977
    else
f312977
        success "$name shutdown"
f312977
    fi
af41006
    echo
af41006
    [ $retval -eq 0 ] && rm -f $lockfile
af41006
    return $retval
af41006
}
af41006
af41006
restart() {
af41006
    stop
af41006
    start
af41006
}
af41006
af41006
rh_status() {
f312977
    status -p $pidfile $name
af41006
}
af41006
af41006
rh_status_q() {
af41006
    rh_status >/dev/null 2>&1
af41006
}
af41006
af41006
af41006
case "$1" in
af41006
    start)
af41006
        rh_status_q && exit 0
af41006
        $1
af41006
        ;;
af41006
    stop)
af41006
        rh_status_q || exit 0
af41006
        $1
af41006
        ;;
af41006
    restart)
af41006
        $1
af41006
        ;;
af41006
    status)
af41006
        rh_status
af41006
        ;;
af41006
    condrestart|try-restart)
af41006
        rh_status_q || exit 0
af41006
        restart
af41006
        ;;
af41006
    *)
af41006
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart}"
af41006
        exit 2
af41006
esac
af41006
exit $?