#!/bin/sh # # Example config.yaml: # output: /var/www/html/tss/ # devices: # device1: # deviceid: iPhone11,8 # board: n841ap # ecid: ecidhere # generator: genhere # apnonce: apnonce # device2: # deviceid: iPhone12,1 # board: n104ap # ecid: ecidhere # generator: genhere # apnonce: apnonce # if ! command -v yq >/dev/null; then printf "Please install yq\nhttps://github.com/mikefarah/yq\n" missingdep=1 fi if ! command -v jq >/dev/null; then printf "Please install jq\nhttps://github.com/stedolan/jq\n" missingdep=1 fi if ! command -v tsschecker >/dev/null; then printf "Please install tsschecker\nhttps://github.com/1Conan/tsschecker\n" missingdep=1 fi if ! command -v pzb >/dev/null; then printf "Please install pzb\nhttps://github.com/tihmstar/partialZipBrowser\n" missingdep=1 fi [ ! -z "${missingdep}" ] && exit 1 if [ -z "${1}" ]; then printf "Usage: tsssave configfile\n" exit 1 fi config="$(realpath "${1}")" output="$(yq e ".output" ${config})" mkdir -p "${output}" cd "$(yq e '.temppath // "/tmp"' ${config})" for device in $(yq e '.devices | keys | .[]' ${config}); do deviceid="$(yq e ".devices.${device}.deviceid" ${config})" board="$(yq e ".devices.${device}.board" ${config})" ecid="$(yq e ".devices.${device}.ecid" ${config})" generator="$(yq e ".devices.${device}.generator" ${config})" apnonce="$(yq e ".devices.${device}.apnonce" ${config})" # RELEASE VERSIONS for signed in $(curl -s https://api.ipsw.me/v4/device/${deviceid} | jq -re '.firmwares[] | select(.signed == true) | .buildid'); do version="$(curl -s https://api.ipsw.me/v4/device/${deviceid} | jq -re ".firmwares[] | select(.buildid == \"${signed}\") | .version")" if [ -e ${output}/${device}/${version}/$(printf "%d\n" ${ecid})_${deviceid}_$(printf "${board}\n" | tr '[A-Z]' '[a-z]')_*-${signed}_*.shsh2 ]; then printf "Skipping %s...\n" ${signed} else printf "Saving %s...\n" ${signed} pzb "$(curl -s https://api.ipsw.me/v4/ipsw/${deviceid}/${signed} | jq -re '.url')" -g BuildManifest.plist -o BuildManifest-${board}-${signed}.plist mkdir -p ${output}/${device}/${version}/ tsschecker -d "${deviceid}" -B "${board}" -m /tmp/BuildManifest-${board}-${signed}.plist -s -e "${ecid}" --generator "${generator}" \ --apnonce "${apnonce}" --save-path ${output}/${device}/${version}/ fi done # BETA VERSIONS for signed in $(curl -sL https://api.m1sta.xyz/betas/${deviceid} | jq -re '.[] | select(.signed == true) | .buildid'); do version="$(curl -s https://api.m1sta.xyz/betas/${deviceid} | jq -re ".[] | select(.buildid == \"${signed}\") | .version" | sed 's/ /-/g')" if [ -e ${output}/${device}/${version}/$(printf "%d\n" ${ecid})_${deviceid}_$(printf "${board}\n" | tr '[A-Z]' '[a-z]')_*-${signed}_*.shsh2 ]; then printf "Skipping %s...\n" ${signed} else printf "Saving %s...\n" ${signed} pzb "$(curl -sL https://api.m1sta.xyz/betas/${deviceid} | jq -re ".[] | select(.buildid == \"${signed}\") | .url")" -g BuildManifest.plist -o BuildManifest-${board}-${signed}.plist mkdir -p ${output}/${device}/${version}/ tsschecker -d "${deviceid}" -B "${board}" -m /tmp/BuildManifest-${board}-${signed}.plist -s -e "${ecid}" --generator "${generator}" \ --apnonce "${apnonce}" --save-path ${output}/${device}/${version}/ fi done done