#!/bin/bash
#
# We use the jobtracker as provisioning server
#
HOSTNAME=$( hostname -f )
DOMAIN_N="t.hadoop.research-infrastructures.eu"
export PATH="/sbin:/usr/sbin:$PATH"

ARG=$1
NAMENODE={{ secondary_nm_hostname }}
SERVICE_SCRIPT=service
STARTUP_SCRIPT=hue
REMOTE_CMD=ssh

case "$ARG" in
  start)
#        $REMOTE_CMD $NAMENODE restart-ntp
	echo "Running $STARTUP_SCRIPT $ARG on host $NAMENODE"
        $REMOTE_CMD $NAMENODE $SERVICE_SCRIPT $STARTUP_SCRIPT start
        ;;
  restart|reload|force-reload)
#        $REMOTE_CMD $NAMENODE restart-ntp
	echo "Running $STARTUP_SCRIPT $ARG on host $NAMENODE"
        $REMOTE_CMD $NAMENODE $SERVICE_SCRIPT $STARTUP_SCRIPT restart
        ;;
  status)
	echo "Running $STARTUP_SCRIPT $ARG on host $NAMENODE"
        $REMOTE_CMD $NAMENODE $SERVICE_SCRIPT $STARTUP_SCRIPT status
        ;;
  stop)
	echo "Running $STARTUP_SCRIPT $ARG on host $NAMENODE"
        $REMOTE_CMD $NAMENODE $SERVICE_SCRIPT $STARTUP_SCRIPT stop
        ;;
  *)
        echo "Usage: $0 start|stop|restart|status" >&2
        exit 3
        ;;
esac

exit 0
