#!/bin/bash

# Gets status of instance

# Exit on any errors
set -e

function print_help {
    echo "Usage: $0 app-name namespace uuid"
    echo "Get application status"

    echo "$0 $@" | logger -p local0.notice -t openshift_origin_mysql_status
    exit 1
}

while getopts 'd' OPTION
do
    case $OPTION in
        d) set -x
        ;;
        ?) print_help
        ;;
    esac
done


[ $# -eq 3 ] || print_help

source "/etc/openshift/node.conf"
source ${CARTRIDGE_BASE_PATH}/abstract/info/lib/util

setup_basic_hook "$1" $2 $3

#
# Get the status of the application
#

if output=$(run_as_user "${CARTRIDGE_BASE_PATH}/mysql-5.1/info/bin/app_ctl.sh status" 2>&1)
then
    status_client_result "$output"
else
    client_result "MySQL is either stopped or inaccessible"
fi
