#!/bin/bash
#
# onapp-redis This script manages Redis server
#
# chkconfig:       - 88 13
# description:     Wrapper over Redis init script \
# which returns exit codes, unacceptable for Pacemaker
# Source onapp functions
. /onapp/interface/script/init/onapp_functions.sh
MYSQL=/etc/init.d/mysql

normalize(){
    exit_code=$1

    if [ "x$exit_code" = "x0" ]; then
        return 0
    else
        return 1
    fi
}

usage(){
    generic_usage
}

start(){
    if pgrep mysql > /dev/null; then
        return 1
    else
        ${MYSQL} start
        normalize $?
    fi
}

stop(){
    if pgrep mysql > /dev/null; then
        ${MYSQL} stop
        normalize $?
    else
        return 1
    fi
}

restart(){
    ${MYSQL} restart
    normalize $?
}

status(){
    ${MYSQL} status
    normalize $?
}

case "$1" in
    status)
        status
        ;;
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    *)
        usage
        ;;
esac
