1#!/usr/bin/env bash 2 3############################################################################### 4# 5# Copyright (C) 2009-2013 Nintendo. All rights reserved. 6# 7# These coded instructions, statements, and computer programs contain 8# proprietary information of Nintendo of America Inc. and/or Nintendo 9# Company Ltd., and are protected by Federal copyright law. They may 10# not be disclosed to third parties or copied or duplicated in any form, 11# in whole or in part, without the prior written consent of Nintendo. 12# 13############################################################################### 14 15if [ "$_" = "$0" ] 16then 17 echo "$(basename $0): Error! I can't be run as a script." 18 echo 19 echo "Please run as:" 20 echo " source $(basename $0) $@" 21 echo " - or -" 22 echo " . $(basename $0) $@" 23 echo 24 exit 1 25fi 26 27# Run setbridgeconfig to update INI file 28setbridgeconfig.exe "$@" 29if [ $? != 0 ] 30then 31 # Something went wrong; setbridgeconfig should have 32 # issued an error message, so let's just die here. 33 return 1 34fi 35 36# Find bridge name ==> first argument that's not an option (something starting with a dash) 37unset bridge_name 38unset is_default 39for arg 40do 41 if [ "${arg:0:1}" != "-" -a -z "$bridge_name" ] 42 then 43 bridge_name=$arg 44 fi 45 if [ "$arg" = "-default" ] 46 then 47 is_default=" (and default)" 48 fi 49done 50 51# Parse bridge_env.ini file, looking for $bridge_name 52OLD_IFS=$IFS 53IFS="=" 54while read name ipaddr 55do 56 if [ "$name" = "${name#BRIDGE_NAME_}" ] 57 then 58 # It's not a bridge/IP line 59 continue 60 fi 61 62 # Remove the "BRIDGE_NAME_" prefix 63 name=${name#BRIDGE_NAME_} 64 65 # If we've found the $bridge_name, save off the IP address 66 if [ "$name" == "$bridge_name" ] 67 then 68 bridge_ipaddr=$ipaddr 69 fi 70done < "${APPDATA}/bridge_env.ini" 71 72# Set variables 73if [ -z "$bridge_ipaddr" ] 74then 75 # Must've deleted a bridge with "-d" option... 76 # TODO: Should I clear the BRIDGE_CURRENT_* variables, or set them to 77 # the default bridge, if we cleared the current session's bridge? 78 echo "Cleared stored IP address for $bridge_name (current environment unchanged)." 79else 80 echo "Setting hostbridge for current session$is_default to $bridge_name $bridge_ipaddr." 81 export BRIDGE_CURRENT_NAME=$bridge_name 82 export BRIDGE_CURRENT_IP_ADDRESS=$bridge_ipaddr 83fi 84 85IFS=$OLD_IFS 86unset arg is_default name ipaddr bridge_name bridge_ipaddr OLD_IFS 87 88if [ "$SESSION_MANAGER" == "1" ] 89then 90 export SESSION_NAME=`"$MION_BRIDGE_TOOLS/SessionManagerUtil.exe" -p NAME` 91 export SESSION_DEBUG_OUT_PORT=`"$MION_BRIDGE_TOOLS/SessionManagerUtil.exe" -p DEBUG_OUT` 92 export SESSION_DEBUG_CONTROL_PORT=`"$MION_BRIDGE_TOOLS/SessionManagerUtil.exe" -p DEBUG_CONTROL` 93 export SESSION_HIO_OUT_PORT=`"$MION_BRIDGE_TOOLS/SessionManagerUtil.exe" -p HIO_OUT` 94 export SESSION_LAUNCH_CTRL_PORT=`"$MION_BRIDGE_TOOLS/SessionManagerUtil.exe" -p LAUNCH_CTRL` 95 export SESSION_NET_MANAGE_PORT=`"$MION_BRIDGE_TOOLS/SessionManagerUtil.exe" -p NET_MANAGE` 96 export SESSION_PCFS_SATA_PORT=`"$MION_BRIDGE_TOOLS/SessionManagerUtil.exe" -p PCFS_SATA` 97 98 export SESSION_PATH_PREFIX=${SESSION_NAME}_ 99 100 export CAFE_DATA_DIR=$CAFE_ROOT/${SESSION_PATH_PREFIX}data 101 export CAFE_CONTENT_DIR=$CAFE_DATA_DIR/disc/content 102 export CAFE_META_DIR=$CAFE_DATA_DIR/disc/meta 103 export CAFE_SAVE_DIR=$CAFE_DATA_DIR/save 104 export CAFE_SLC_DIR=$CAFE_DATA_DIR/slc 105 export CAFE_MLC_DIR=$CAFE_DATA_DIR/mlc 106 export CAFE_DATA_TMP=$CAFE_DATA_DIR/tmp 107 108 # Updates the window title 109 source $CAFE_ROOT/system/bin/tool/cafe_profile.sh 110fi 111