#!/bin/bash
# Shell wrapper to execute "$MAHOUT_HOME/bin/mahout"
# as a hadoop user.

CMDNAME=`basename "$0"`

export JAVA_HOME=@java_home@
export HADOOP_HOME=@hadoop_home@
export HADOOP_CONF_DIR=$HADOOP_HOME/conf
export MAHOUT_HOME=@mahout_home@
export MAHOUT_LOG_DIR=@mahout_log_dir@

SCRIPT="$MAHOUT_HOME/bin/mahout"

usage() {
  echo "Usage: $CMDNAME [-h|--help] [-core] args"
  echo "Executes \"$SCRIPT\" as @hadoopuser@ user"
  exit 1
}

if [ $# -eq 0 -o "$1" = "-h" -o "$1" = "--help" ]; then
    usage
fi

exec sudo -E -u @hadoopuser@ $SCRIPT "$@"
