#!/bin/bash

# Starts instance

# Exit on any errors
set -e

function print_help {
    echo "Usage: $0 app-name namespace uuid"
    echo "Start a running application"

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

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


[ $# -eq 3 ] || print_help

cartridge_type="mysql-5.1"
source "/etc/openshift/node.conf"
source ${CARTRIDGE_BASE_PATH}/abstract/info/lib/util

setup_basic_hook "$1" $2 $3

MYSQL_DIR=$(get_cartridge_instance_dir "$cartridge_type")

#
# Start application
#
rm -f "$MYSQL_DIR/run/stop_lock"
super_run_as_user "${CARTRIDGE_BASE_PATH}/$cartridge_type/info/bin/app_ctl.sh start"
