]> git.cameronkatri.com Git - tsssave.git/blob - tsssave
Add tsssave
[tsssave.git] / tsssave
1 #!/bin/sh
2 #
3 # Example config.yaml:
4 # output: /var/www/html/tss/
5 # devices:
6 # device1:
7 # deviceid: iPhone11,8
8 # board: n841ap
9 # ecid: ecidhere
10 # generator: genhere
11 # apnonce: apnonce
12 # device2:
13 # deviceid: iPhone12,1
14 # board: n104ap
15 # ecid: ecidhere
16 # generator: genhere
17 # apnonce: apnonce
18 #
19
20 if ! command -v yq; then
21 printf "Please install yq\nhttps://github.com/mikefarah/yq\n"
22 missingdep=1
23 fi
24
25 if ! command -v jq; then
26 printf "Please install jq\nhttps://github.com/stedolan/jq\n"
27 missingdep=1
28 fi
29
30 if ! command -v tsschecker; then
31 printf "Please install tsschecker\nhttps://github.com/1Conan/tsschecker\n"
32 missingdep=1
33 fi
34
35 if ! command -v pzb; then
36 printf "Please install pzb\nhttps://github.com/tihmstar/partialZipBrowser\n"
37 missingdep=1
38 fi
39
40 [ ! -z "${missingdep}" ] && exit 1
41
42 if [ -z "${1}" ]; then
43 printf "Usage: tsssave configfile\n"
44 exit 1
45 fi
46
47 config="$(realpath "${1}")"
48
49 output="$(yq e ".output" ${config})"
50
51 mkdir -p "${output}"
52 cd "$(yq e '.temppath // "/tmp"' ${config})"
53
54 for device in $(yq e '.devices | keys | .[]' ${config}); do
55 deviceid="$(yq e ".devices.${device}.deviceid" ${config})"
56 board="$(yq e ".devices.${device}.board" ${config})"
57 ecid="$(yq e ".devices.${device}.ecid" ${config})"
58 generator="$(yq e ".devices.${device}.generator" ${config})"
59 apnonce="$(yq e ".devices.${device}.apnonce" ${config})"
60
61 # RELEASE VERSIONS
62
63 for signed in $(curl -s https://api.ipsw.me/v4/device/${deviceid} | jq -re '.firmwares[] | select(.signed == true) | .buildid'); do
64 version="$(curl -s https://api.ipsw.me/v4/device/${deviceid} | jq -re ".firmwares[] | select(.buildid == \"${signed}\") | .version")"
65 if [ -e ${output}/${version}/$(printf "%d\n" ${ecid})_${deviceid}_$(printf "${board}\n" | tr '[A-Z]' '[a-z]')_*-${signed}_*.shsh2 ]; then
66 printf "Skipping %s...\n" ${signed}
67 else
68 printf "Saving %s...\n" ${signed}
69 pzb "$(curl -s https://api.ipsw.me/v4/ipsw/${deviceid}/${signed} | jq -re '.url')" -g BuildManifest.plist -o BuildManifest-${board}-${signed}.plist
70 mkdir -p ${output}/${device}/${version}/
71 tsschecker -d "${deviceid}" -B "${board}" -m /tmp/BuildManifest-${board}-${signed}.plist -s -e "${ecid}" --generator "${generator}" \
72 --apnonce "${apnonce}" --save-path ${output}/${device}/${version}/
73 fi
74 done
75
76 # BETA VERSIONS
77
78 for signed in $(curl -sL https://api.m1sta.xyz/betas/${deviceid} | jq -re '.[] | select(.signed == true) | .buildid'); do
79 version="$(curl -s https://api.m1sta.xyz/betas/${deviceid} | jq -re ".[] | select(.buildid == \"${signed}\") | .version")"
80 if [ -e ${output}/${version}/beta/$(printf "%d\n" ${ecid})_${deviceid}_$(printf "${board}\n" | tr '[A-Z]' '[a-z]')_*-${signed}_*.shsh2 ]; then
81 printf "Skipping %s...\n" ${signed}
82 else
83 printf "Saving %s...\n" ${signed}
84 pzb "$(curl -sL https://api.m1sta.xyz/betas/${deviceid} | jq -re ".[] | select(.buildid == \"${signed}\") | .url")" -g BuildManifest.plist -o BuildManifest-${board}-${signed}.plist
85 mkdir -p ${output}/${device}/${version}/
86 tsschecker -d "${deviceid}" -B "${board}" -m /tmp/BuildManifest-${board}-${signed}.plist -s -e "${ecid}" --generator "${generator}" \
87 --apnonce "${apnonce}" --save-path ${output}/${device}/${version}/beta/
88 fi
89 done
90 done