#!/bin/sh
#
#  $Id: //depot/prod/spinfs/rel2.5.4x/mgmt/src/scripts/shutdown#1 $
#
#  script to redirect callers of the shutdown command
#
#
action="halt" 

if [ "$1" ] ; then
	if [ "$1" == "-r" ] ; then
		action="reboot"
		shift
		if [ "$1" ] ; then
			if [ "$1" == "now" ] ; then
				shift
			fi
		fi
	fi
fi

if [ $action == "halt" ] ; then
	echo "spinserver shutdown process started"
else
	echo "spinserver reboot process started"
fi

if [ ! "$1" ] ; then
	echo -n "ssid: "
	read ssid
else
	ssid="$1"
fi

if [ ! "$2" ] ; then
	echo -n "reason: "
	read reason
else
	reason="$2"
fi

if [ $action == "halt" ] ; then
	spinsh -c spinserver shutdown -ssid \""$ssid"\" -shutdownreason \""$reason"\"
else
	spinsh -c spinserver reboot -ssid \""$ssid"\" -rebootreason \""$reason"\"
fi

