#!/usr/bin/env bash ############################################################################### # # Copyright (C) 2009-2013 Nintendo. All rights reserved. # # These coded instructions, statements, and computer programs contain # proprietary information of Nintendo of America Inc. and/or Nintendo # Company Ltd., and are protected by Federal copyright law. They may # not be disclosed to third parties or copied or duplicated in any form, # in whole or in part, without the prior written consent of Nintendo. # ############################################################################### if [ ! -n "$SDIO_BRIDGE_TOOLS" ] then if [ ! -n "$MION_BRIDGE_TOOLS" ] then echo "hoststop failed: Please install HostBridgeSetup and restart cafe.bat." exit 1 fi fi HOSTSTOP_RVAL=0 HOSTSTOP_RETRIES=0 source getbridgetype HOSTSTOP_RESET_OPTION=-SMCResetHold if [ "${CAFE_HARDWARE:0:2}" == "ev" ] then HOSTSTOP_RESET_OPTION=-hold export MION_PWR_SEQ=FOFF1 fi # make FOFF2 the default power sequence if [ "$BRIDGE_TYPE" == "Mion" ] then checkbridgename $BRIDGE_CURRENT_NAME -ip $BRIDGE_CURRENT_IP_ADDRESS if [ "$1" == "-makemine" ] then ToucanReset -stop "$MION_BRIDGE_TOOLS/FSEmul.exe" -ip $BRIDGE_CURRENT_IP_ADDRESS -makemine fi if [ "$MION_PWR_SEQ" == "smcreset" ] then "$MION_BRIDGE_TOOLS/MionButton.exe" -ip $BRIDGE_CURRENT_IP_ADDRESS -rsthold "$@" HOSTSTOP_RVAL=$? else if [ "$MION_PWR_SEQ" == "FOFF1" ] then "$MION_BRIDGE_TOOLS/MionButton.exe" -ip $BRIDGE_CURRENT_IP_ADDRESS -forceOff1 "$@" HOSTSTOP_RVAL=$? else if [ "$MION_PWR_SEQ" == "G_SHUTDOWN" ] then "$MION_BRIDGE_TOOLS/MionButton.exe" -ip $BRIDGE_CURRENT_IP_ADDRESS -init_shutdown_w_FOFF2 60000 "$@" HOSTSTOP_RVAL=$? else # Poor network conditions sometimes prevent MionButton from succeeding - # so adding retry logic HOSTSTOP_RVAL=1 HOSTSTOP_RETRIES=0 while [ $HOSTSTOP_RVAL -ne 0 -a $HOSTSTOP_RETRIES -lt 4 ] do if [ $HOSTSTOP_RETRIES -gt 0 ] then echo "WARNING: MionButton powerdown failed with err=$HOSTSTOP_RVAL, will retry shortly, count=$HOSTSTOP_RETRIES" sleep 30 fi "$MION_BRIDGE_TOOLS/MionButton.exe" -ip $BRIDGE_CURRENT_IP_ADDRESS -forceOff2_off_single_cgi "$@" HOSTSTOP_RVAL=$? ((HOSTSTOP_RETRIES=HOSTSTOP_RETRIES+1)) done fi fi fi if [ $HOSTSTOP_RVAL -gt 2 ] then # # We have a return from mionbutton that indicates the bridge may be in a bad state. # echo "Gathering MION logs via telnet for the mionbutton return of $HOSTSTOP_RVAL." echo "----------------------------------------------------------------" >> "$TMP/${SESSION_PATH_PREFIX}cafestop_mion.log" echo "----- MION telnet debug log @ `date` -----" >> "$TMP/${SESSION_PATH_PREFIX}cafestop_mion.log" echo "----------------------------------------------------------------" >> "$TMP/${SESSION_PATH_PREFIX}cafestop_mion.log" miontelnet.exe $BRIDGE_CURRENT_IP_ADDRESS >> "$TMP/${SESSION_PATH_PREFIX}cafestop_mion.log" echo " See $TMP/${SESSION_PATH_PREFIX}cafestop_mion.log for details." fi else nohup ToucanReset $HOSTSTOP_RESET_OPTION < /dev/null &> /dev/null HOSTSTOP_RVAL=$? fi # stop FSEmul.exe ToucanReset -stop if [ $HOSTSTOP_RVAL -ne 0 ] then if [ "$BRIDGE_TYPE" == "Mion" ] then if [ "$MION_PWR_SEQ" == "G_SHUTDOWN" -a $HOSTSTOP_RVAL -eq 1 ] then echo "hoststop warning: Software shutdown failed." HOSTSTOP_RVAL=0 else echo "hoststop failed: Could not stop cafe through '$BRIDGE_CURRENT_NAME'." checkbridgename -s -ip $BRIDGE_CURRENT_IP_ADDRESS fi else echo "hoststop failed: Could not stop cafe through Toucan." fi fi