#!/bin/bash
exec 2>&1

command=<%= @options[:command_name] || @options[:service_name] %>

# Include hbase defaults if available
if [ -f "/etc/default/hbase" ] ; then
  .     "/etc/default/hbase"
fi

if [ -f "<%= @options[:home_dir] %>/bin/hbase-config.sh" ] ; then
  .     "<%= @options[:home_dir] %>/bin/hbase-config.sh"
fi

if [ -f "<%= @options[:conf_dir] %>/hbase-env.sh" ] ; then
  .     "<%= @options[:conf_dir] %>/hbase-env.sh"
fi

# some variables normally set by bin/hbase-daemon.sh 
export HBASE_LOGFILE=hbase-$HBASE_IDENT_STRING-$command-$HBASE_NODENAME.log
export HBASE_ROOT_LOGGER="INFO,DRFA"

cd "$HBASE_HOME"
exec chpst -u <%= @options[:user] %> "$HBASE_HOME"/bin/hbase $command start "$@" < /dev/null
