From 95fa827e3c11799ea1ea4ee431fa805a9a55dbf2 Mon Sep 17 00:00:00 2001 From: LukeeGD <26163116+LukeZGD@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:09:03 +0800 Subject: [PATCH] Update ipsw_get_url for edge cases example: 5c/5s 7.0 --- restore.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/restore.sh b/restore.sh index 432bb7c..b5a922d 100755 --- a/restore.sh +++ b/restore.sh @@ -2094,6 +2094,7 @@ device_fw_key_check() { ipsw_get_url() { local build_id="$1" local url="$(cat "$device_fw_dir/$build_id/url" 2>/dev/null)" + local url_local="$url" ipsw_url= log "Checking URL in $device_fw_dir/$build_id/url" if [[ $(echo "$url" | grep -c '<') != 0 || $url != *"$build_id"* ]]; then @@ -2103,9 +2104,19 @@ ipsw_get_url() { if [[ -z $url ]]; then log "Getting URL for $device_type-$build_id" url="$(curl "https://api.ipsw.me/v4/ipsw/$device_type/$build_id" | $jq -j ".url")" - if [[ $(echo "$url" | grep -c '<') != 0 ]]; then + if [[ $(echo "$url" | grep -c '<') != 0 || $url != *"$build_id"* ]]; then url="$(curl "https://api.ipsw.me/v4/device/$device_type?type=ipsw" | $jq -j ".firmwares[] | select(.buildid == \"$build_id\") | .url")" fi + if [[ $(echo "$url" | grep -c '<') != 0 || $url != *"$build_id"* ]]; then + if [[ -n $url_local ]]; then + url="$url_local" + log "Using saved URL for this IPSW: $url" + echo "$url" > $device_fw_dir/$build_id/url + ipsw_url="$url" + return + fi + error "Unable to get URL for $device_type-$build_id" + fi mkdir -p $device_fw_dir/$build_id 2>/dev/null echo "$url" > $device_fw_dir/$build_id/url fi