#!/bin/sh
#
#    Copyright (c) 2001 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#    File name:   reboot
#    Module name: fabos/src/utils/sys
#
#    This script is wrapper to the traditional /sbin/reboot command 
#    so that /fabos/sbin/ will contain this wrapper to allow admin account
#    to use it. admin account should not have /sbin directly in its PATH.
#
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/fabos/bin:/fabos/sbin

HWMODEL=`/sbin/sin | /bin/grep "Platform" | /bin/sed -e"s/[ ]*//g" | /usr/bin/cut -d, -f1 | /usr/bin/cut -d: -f2 2> /dev/null`

ACTIVE=`hashow | grep Local | sed -e "s/[ ]*//g" | cut -d: -f2`

if [ "$HWMODEL" = "SWBD10" ]; then
# Only prompt user on active Ulysses cp...
	if [ "$ACTIVE" = "Active" ]; then
printf "Warning: This command is being run on a control processor (CP)\n"
printf "based system and will cause the active CP to reboot. This will\n"
printf "cause disruption to devices attached to both switch 0 and switch 1\n"
printf "and will require that existing telnet sessions be restarted.\n"
printf "To just reboot a logical switch on this system, use command\n"
printf "switchreboot(1M) on the logical switch you intend to reboot.\n"
printf "\nAre you sure you want to reboot the active CP [y/n]? "
		read in
		if [ "$in" = "y" -o "$in" = "Y" ]; then
			export PATH=/sbin
			/sbin/reboot $*
		fi
	else
		#
		# On a standby CP, just reboot. 
		#
		/sbin/reboot $*
	fi
else
#
# For other platform (e.g. Terminator), just do reboot.
#
	/sbin/reboot $*
fi
