#!/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. # ############################################################################### ################################################################################ # caferecover # This script updates a DEV-KIT to boot using the DUAL bootloader ################################################################################ if [ "$USE_CAFEX" == "1" ] then # Set IFS to something that will not be in the args, so that BASH will pass the entire un-parsed string to CafeX saveIFS="$IFS" IFS=$'\n' echo "Using CafeControl" cafex.exe cleardata $@ rval=$? IFS="$saveIFS" exit $rval fi #------------------------------------------------------------------------------ #---- initialization #------------------------------------------------------------------------------ source cafe_utils SCRIPT_EXE_TIMESTAMP=`date +%m_%d_%Y_%H%M%S` LOGDIR="$CAFE_TEMP/`basename "$0"`/${SCRIPT_EXE_TIMESTAMP}" echo `basename "$0"` echo log directory is $LOGDIR mkdir -p "$LOGDIR" CAFE_CONSOLE=toucan #------------------------------------------------------------------------------ #---- cafeon #------------------------------------------------------------------------------ source hostcheckversion hb_ver_flat=$(compute_flat_version $CAFERUN_HOSTBRIDGE_VERSION) echo Executing cafeon"..." set -e if [ $hb_ver_flat -lt $(compute_flat_version 3.2.4.1) ] then cafeon 1> "$LOGDIR"/cafeon.txt 2>&1 else cafeon -e nomodecheck 1> "$LOGDIR"/cafeon.txt 2>&1 fi if [ -e "$TMP/${SESSION_PATH_PREFIX}cafestop_mion.log" ]; then mv "$TMP/${SESSION_PATH_PREFIX}cafestop_mion.log" "${LOGDIR}/cafeon_mion.log" fi set +e Monitor_For_Output -k "source -p -q /vol/content/" $MONITOR_DEFAULT_TIMEOUT "$LOGDIR" if [ $? -ne 0 ]; then echo `basename "$0"`: monitor failed waiting for cafeon success message. exit 1 fi #------------------------------------------------------------------------------ #---- recover command #------------------------------------------------------------------------------ echo Executing devkitmsg recover -v"..." set -e devkitmsg recover -v -p $SESSION_LAUNCH_CTRL_PORT set +e Monitor_For_Output -K "WUD_BCMFWCheck" $MONITOR_DEFAULT_TIMEOUT "$LOGDIR" #note: need -K here, not -k if [ $? -ne 0 ]; then echo `basename "$0"`: monitor failed waiting for devkitmsg recover success message. exit 1 fi #------------------------------------------------------------------------------ #---- clr_usrdata command #------------------------------------------------------------------------------ echo Executing devkitmsg clr_usrdata -v"..." set -e devkitmsg clr_usrdata -v -p $SESSION_LAUNCH_CTRL_PORT set +e Monitor_For_Output -k "Done, err 0" $MONITOR_DEFAULT_TIMEOUT "$LOGDIR" if [ $? -ne 0 ]; then echo `basename "$0"`: monitor failed waiting for devkitmsg clr_usrdata success message. exit 1 fi #------------------------------------------------------------------------------ #---- cafestop #------------------------------------------------------------------------------ echo Executing cafestop"..." source cafestop 1> "$LOGDIR"/cafestop1.txt 2>&1 if [ -e "$TMP/${SESSION_PATH_PREFIX}cafestop_mion.log" ]; then mv "$TMP/${SESSION_PATH_PREFIX}cafestop_mion.log" "${LOGDIR}/cafestop1_mion.log" fi if [ $CAFESTOP_STATUS -ne 0 ]; then echo `basename "$0"`: cafestop failure. exit 1 fi #------------------------------------------------------------------------------ #---- success! #------------------------------------------------------------------------------ echo Removing log directory $LOGDIR"..." rm -rf "$LOGDIR" echo `basename "$0"` complete. Exiting with code 0. exit $rval