#!/bin/sh

# Copyright C 2002-2008 by Isilon Systems, Inc. All rights not expressly
# granted herein are reserved.
# Created in the United States of America.
# 
# This digital media is protected by U.S. and international copyright and
# intellectual property laws. Unless otherwise specified, all information
# and screens appearing as part of this digital medium, including
# software, services, documents, text, images, icons, and logos design;
# the selection, assembly, arrangement, and design thereof; and the code
# that enables its presentation, are the sole property of Isilon Systems,
# Inc.
# 
# Except as otherwise required by applicable law, no part of any
# copyrighted material may be reproduced, modified, translated,
# distributed, published, or transmitted by any means, electronic or
# mechanical, for any purpose, without the prior written consent of Isilon
# Systems. 
#  
# Isilon and Isilon Systems are registered trademarks of Isilon Systems,
# Inc.  Legion is a trademark of Isilon Systems, Inc.  All other
# trademarks and registered trademarks are the property of their
# respective holders.

echo "**Warning**: isi_hard_reboot is designed to reboot a system that is"
echo "deadlocked. Beware that it will bypass standard userspace system"
echo "shutdown.  As such, it will not cleanly stop services, flush buffers, or" 
echo "otherwise clean up.  If used at the wrong time, this command can"
echo "risk boot-disk corruption (and if your journal batteries are bad,"
echo "OneFS data loss."

TIMEOUT=120

while [ -n "$1" ]; do
    case $1 in
	-f| --force)
	    prompt=false ;;
    esac
    shift
done

if ${prompt:-true}; then
	echo -n "Are you sure (yes/no) [no]? "
	read -t ${TIMEOUT} ANSWER
	if [ "${ANSWER:=no}" != "yes" ]; then
		echo "Quit without reboot"
		exit;
	fi
fi

/sbin/kldload reboot_me
