-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathupdate.sh
More file actions
60 lines (42 loc) · 1.29 KB
/
update.sh
File metadata and controls
60 lines (42 loc) · 1.29 KB
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
#!/bin/sh
set -e
TMPDIR=/mnt/us/KF-Update-Temp
alert() {
TITLE="$1"
TEXT="$2"
TITLE_ESC=$(printf '%s' "$TITLE" | sed 's/"/\\"/g')
TEXT_ESC=$(printf '%s' "$TEXT" | sed 's/"/\\"/g')
JSON='{ "clientParams":{ "alertId":"appAlert1", "show":true, "customStrings":[ { "matchStr":"alertTitle", "replaceStr":"'"$TITLE_ESC"'" }, { "matchStr":"alertText", "replaceStr":"'"$TEXT_ESC"'" } ] } }'
lipc-set-prop com.lab126.pillow pillowAlert "$JSON"
}
# Failsafe
failsafe() {
CODE=$?
if [ "$CODE" != 0 ]; then
alert "Update Failed!" "Something Went Wrong!\nExit Code: $CODE"
sync
fi
}
trap failsafe EXIT
rm -rf "$TMPDIR"
mkdir -p "$TMPDIR"
alert "Updating..." "Updating KindleForge, Please Wait..."
# Download + Extract
curl -fSL -o "$TMPDIR/KindleForge.zip" \
https://github.com/KindleTweaks/KindleForge/releases/latest/download/KindleForge.zip
unzip -q "$TMPDIR/KindleForge.zip" -d "$TMPDIR"
# Delete Old Version
rm -rf /mnt/us/documents/KindleForge
rm -f /mnt/us/documents/KindleForge.sh
# Install New Version
cp -r "$TMPDIR"/* /mnt/us/documents/
sync
sleep 1
rm -rf "$TMPDIR"
# Go Home
lipc-set-prop com.lab126.appmgrd start app://com.lab126.booklet.home
sleep 2
killall mesquite || true
sleep 2
alert "Updating Complete!" "You May Now Use KindleForge."
exit 0