#!/bin/sh
# -*- tab-width:4;indent-tabs-mode:nil -*-
# ex: ts=4 sw=4 et

SCRIPT="stanchion-admin"

PLATFORM_BASE_DIR=${STANCHION_PATH:-$(cd $(dirname "$0")/.. && pwd -P)}

PLATFORM_BIN_DIR=/usr/lib64/stanchion/bin
if [ "$PLATFORM_BIN_DIR" = "${PLATFORM_BIN_DIR#/}" ]; then
    PLATFORM_BIN_DIR=$PLATFORM_BASE_DIR/$PLATFORM_BIN_DIR
fi

RPC_HOP="${PLATFORM_BIN_DIR}/stanchion rpc"

# if we ever need to start a separate node to do fancier stuff than we
# can via rpc, see how this is done in riak/rel/files/riak-admin


usage() {
    echo "Usage: $SCRIPT { version | status }"
}

# Check the first argument for instructions
case "$1" in
    version)
        shift
        $RPC_HOP stanchion_console version
        ;;
    status)
        shift
        $RPC_HOP stanchion_console status
        ;;
    *)
        usage
        exit 1
        ;;
esac
