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

PLATFORM_BASE_DIR=/usr/lib64/riak
PLATFORM_BASE_DIR=${PLATFORM_BASE_DIR:-$(cd $(dirname "$0")/.. && pwd -P)}
RUNNER_GEN_DIR=/var/lib/riak

RELEASE_ROOT_DIR=$PLATFORM_BASE_DIR

ERTS_VER=$(cd ${PLATFORM_BASE_DIR} && ls -d erts-*)
ERTS_DIR="${PLATFORM_BASE_DIR}/$ERTS_VER"

. $PLATFORM_BASE_DIR/bin/cf_config

BOOT_FILE="${PLATFORM_BASE_DIR}/releases/3.2.0/start_clean"

CODE=" try
           {ok, _} = file:consult(\"$CONFIG_PATH\"),
           io:format(\"config is OK\\n\"),
           halt(0)
       catch
           _:_ ->
               io:format(\"Error reading ~p\\n\", [\"$CONFIG_PATH\"]),
               halt(1)
       end."

$ERTS_DIR/bin/erl -noshell -noinput \
                  -boot $BOOT_FILE \
                  -eval "$CODE"

echo $CUTTLE_CONF
