#!/bin/bash
#
# We use the jobtracker as provisioning server
#
HOSTNAME=$( hostname -f )

ARG=$1
TARGET_NODE={{ secondary_nm_hostname }}
STARTUP_SCRIPT_PREFIX=/etc/init.d
STARTUP_SCRIPT=hadoop-hdfs-secondarynamenode
REMOTE_CMD=ssh

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

exit 0
