-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathinstallgithub.sh
More file actions
74 lines (59 loc) · 2.09 KB
/
installgithub.sh
File metadata and controls
74 lines (59 loc) · 2.09 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
archt=$(uname -m | sed -e 's/armv7l/armhf/g')
version=1.1.7
versionpro=1.1.7
ITCHIOFILEPATH="$HOME/.config/itchiokey.txt"
savekey() {
echo "$1" > "$ITCHIOFILEPATH"
}
if [ -f "$ITCHIOFILEPATH" ] && [ -s "$ITCHIOFILEPATH" ]; then
ITCH_API_KEY=$(cat "$ITCHIOFILEPATH")
fi
if [ -n "$ITCH_API_KEY" ]; then
echo "Installing the professional version"
if command -v jq >/dev/null 2>&1; then
jq="jq"
else
if ! [ -f "/tmp/jq" ]; then
jqurl="https://github.com/bakustarver/rpgmakermlinux-cicpoffs/releases/download/libraries/jq.$archt"
wget "$jqurl" -O "/tmp/jq"
chmod +x "/tmp/jq"
jq="/tmp/jq"
fi
fi
page=1
sleep_between=0.5
while [ -z "$id" ]; do
list=$(wget -qO- "https://api.itch.io/profile/owned-keys?api_key=$ITCH_API_KEY&page=$page" ) || {
echo "Error: Cannot get data from server, wrong itch.io key?" >&2
exit 2
}
len=$(printf '%s' "$list" | "$jq" '.owned_keys | length' 2>/dev/null) || {
echo "Error: failed to parse JSON on page with jq" >&2
exit 3
}
if [ "$len" -eq 0 ]; then
echo "Query finished: the professional version was not detected with the provided API key"
exit
fi
id=$(echo "$list" | "$jq" -r '.owned_keys[] | select(.game_id==2577304) | .id')
page=$((page + 1))
sleep "$sleep_between"
done
savekey "$ITCH_API_KEY"
listtar=$(wget -qO- "https://api.itch.io/games/2577304/uploads?download_key_id=$id&api_key=$ITCH_API_KEY" | "$jq" -r '.uploads[] | "\(.filename)->https://api.itch.io/uploads/\(.id)/download"')
#echo "$listtar"
rpgmprotardata=$(echo "$listtar" | grep "$archt")
rpgmprotarurl=$(echo "$rpgmprotardata" | sed -e 's@.*->@@g')
basenametar=$(echo "$rpgmprotardata" | sed -e 's@->.*@@g')
wget "$rpgmprotarurl?download_key_id=$id&api_key=$ITCH_API_KEY" -O "/tmp/$basenametar"
else
echo "Installing the base version"
link="https://github.com/bakustarver/rpgmakermlinux-cicpoffs/releases/download/v$version/rpgmakerlinux-$archt-v$version.tar.gz"
basenametar=$(basename "$link")
wget -P "/tmp/" "$link"
fi
dirtarname=$(echo "$basenametar" | sed -e 's@.tar.gz@@g')
tar -xf "/tmp/$basenametar" -C "/tmp/"
/tmp/$dirtarname/install.sh
rm "/tmp/$basenametar"