-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathget_update.sh
executable file
·68 lines (54 loc) · 1.22 KB
/
get_update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
set -eu
action="$1"
fw_version="${2:-3}"
get_url() {
fw_info=$(jq "[to_entries.[] | select(.key | startswith(\"$1\"))] | max_by(.key)" updates.json)
if [ "$fw_info" = "null" ]
then
echo "Unknown version $1"
exit 1
fi
fw_hash=$(echo "$fw_info" | jq --raw-output '.value')
fw_ver=$(echo "$fw_info" | jq --raw-output '.key')
fw_major=$(echo "$fw_ver" | cut -d '.' -f 1)
fw_url=""
if [ "$fw_major" = "3" ]
then
fw_url="https://updates-download.cloud.remarkable.engineering/build/reMarkable%20Device/reMarkable2"
else
fw_url="https://updates-download.cloud.remarkable.engineering/build/reMarkable%20Device%20Beta/RM110"
fi
fw_url="$fw_url/$fw_ver/${fw_ver}_reMarkable2-$fw_hash.signed"
}
download_fw() {
get_url "$1"
echo "Downloading $fw_ver from:"
echo " $fw_url"
curl -f -o fw.signed "$fw_url"
}
check_fw() {
get_url "$1"
echo "Checking $fw_ver at $fw_url"
curl -f -I "$fw_url"
}
check_all() {
all_fw=$(jq --raw-output 'keys[]' updates.json)
for f in $all_fw
do
check_fw "$f"
done
}
case $action in
download)
download_fw "$fw_version"
;;
check)
check_fw "$fw_version"
;;
check-all)
check_all
;;
*)
;;
esac