#!/usr/bin/env bash # Version 6/27/2012 ############################################################################### # # 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. # ############################################################################### # Path to where ImageUploader.exe will extract the WUMAD to. WUMAD_EXTRACT_TMP=$TMP/${SESSION_PATH_PREFIX}NHBImageUploader ################################################################################################## # Print Usage ################################################################################################## usage() { cat <"$TMP/${SESSION_PATH_PREFIX}imguploaderv.txt" IMGUPLOADERV=`cat "$TMP/${SESSION_PATH_PREFIX}imguploaderv.txt" | grep "Image Uploader by"` fi if [[ $IMGUPLOADERV == *ver.* ]] then IMGUPLOADERV=${IMGUPLOADERV#*.} IMGUPLOADFLAT=0 vpart=0 while [ $vpart -lt 4 ] do # delete all after the first dot IMGVF1=${IMGUPLOADERV%%.*} IMGUPLOADERV=${IMGUPLOADERV#*.} IMGVF1=${IMGVF1//[^0-9]/} ((IMGUPLOADFLAT=IMGUPLOADFLAT*100+IMGVF1)) ((vpart=vpart+1)) done echo "Detected ImageUploader flatversion to be $IMGUPLOADFLAT" else set IMGUPLOADFLAT=$MIN_WUMAD_SUPPORT_UPLOADER echo "WARNING: Unable to query ImageUploader version" fi } ################################################################################################## # WUMAD file path validation check ################################################################################################## wumad_path_check() { if [ ! -f "$wumad_path" ] then echo "Could not find a .wumad file in the specified directory!" echo "Please confirm the file path:" echo " $wumad_path" exit 2 fi #echo "WUMAD file: $wumad_path" } ################################################################################################## # WUMAD file decompression using ImageUploader ################################################################################################## main_image_extract() { echo "Extracting $wumad_path to $WUMAD_EXTRACT_TMP." # Use ImageUploader.exe to just extract the image to a folder ImageUploader.exe -ip 0.0.0.0 -upload 0 "$wumad_path" > wumad_extract.log IMGUPLOAD_RVAL=$? if [ $enable_workarounds -eq 1 ] then # Ignore the return from ImageUploader as it will always be -1 # Workaround for a directory attribute test bug in ImageUploader.exe echo "Changing attributes on $WUMAD_EXTRACT_TMP." attrib -I `cygpath -w "$WUMAD_EXTRACT_TMP"` else # Check the return from ImageUploader to see if we have a successful image extraction if [ $IMGUPLOAD_RVAL -ne 0 ] then echo "$(basename $0): ERROR: Failed to extract $wumad_path!" exit 1 fi fi } ################################################################################################## # Main Image Upload Process ################################################################################################## main_image_upload() { for catdev_ip in $ip_addresses { # Use the output of the image extract on all uploads echo "Uploading $WUMAD_EXTRACT_TMP to bank number $bank_no on Devkit using IP $catdev_ip." uploadimg.sh $bank_no "$WUMAD_EXTRACT_TMP" $catdev_ip > $catdev_ip.log & if [ $enable_workarounds -eq 1 ] then # Workaround for a file share access bug in ImageUploader.exe echo "Sleeping 5 seconds for ImageUploader syncronization." sleep 5 fi } echo "Waiting for all images to finish uploading..." wait } ################################################################################################## # Main ################################################################################################## check_imageuploader_version if [ $IMGUPLOADFLAT -lt 805 ] then # ImageUploader v805 has fixes for the workarounds enable_workarounds=1 fi if [ $skip_extract -eq 0 ] then # Check and extract the WUMAD to the TMP folder wumad_path_check main_image_extract fi # Upload extracted image in TMP folder to DevKits main_image_upload echo "Complete! All images have finished uploading." exit 0