-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathrevancify
executable file
·174 lines (142 loc) · 4.71 KB
/
revancify
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/bash
SRC="$HOME/Revancify"
HELP="revancify
Usage: revancify [OPTION]
Options:
-f: Force re-install Revancify
-u: Disable Update Check
-r: Disable Root access
-v: Print current version
-h: Print help statement"
while getopts ":furvh" OPT 2> /dev/null; do
case $OPT in
f)
rm "$SRC/.info" &> /dev/null
;;
u)
INTERNET_ACCESS=false
;;
r)
ROOT_ACCESS=false
;;
v)
if [ -e "$SRC" ]; then
source "$SRC/.info"
echo "$VERSION"
else
echo "Revancify not installed !!"
fi
exit
;;
h)
echo -e "$HELP"
exit
;;
?)
echo -e "Invalid option specified: -${OPTARG}"
echo -e "$HELP"
exit 1
;;
esac
done
terminate() {
killall -9 curl &> /dev/null
killall -9 wget &> /dev/null
clear
echo "Script terminated !!"
exit 1
}
trap terminate SIGTERM SIGINT SIGABRT
installDependencies() {
local BINS BIN CTR RESPONSE
echo "Checking dependencies..."
[ -e "$HOME/storage" ] || termux-setup-storage
BINS=$(ls "$PREFIX/bin")
grep -q java <<< "$BINS" || PKGS+=("openjdk-21")
grep -q wget <<< "$BINS" || PKGS+=("wget")
grep -q tput <<< "$BINS" || PKGS+=("ncurses-utils")
grep -q dialog <<< "$BINS" || PKGS+=("dialog")
grep -q pup <<< "$BINS" || PKGS+=("pup")
grep -q jq <<< "$BINS" || PKGS+=("jq")
grep -q unzip <<< "$BINS" || PKGS+=("unzip")
if [ "${#PKGS[@]}" -ne 0 ]; then
pkg update || return 1
yes | pkg install "${PKGS[@]}" || return 1
fi
sed -i '/allow-external-apps/s/# //' "$HOME/.termux/termux.properties"
[ -e "$SRC/bin" ] || mkdir -p "$SRC/bin"
AAPT2="$SRC/bin/aapt2"
APK_EDITOR="$SRC/bin/APKEditor.jar"
CTR=0 && while [ ! -e "$AAPT2" ]; do
[ $CTR -gt 2 ] && return 1
echo -e "\nDownloading aapt2...\n"
readarray -t RESPONSE < <(curl -s "https://api.github.com/repos/decipher3114/binaries/releases/latest" | jq -r --arg ARCH "$(getprop ro.product.cpu.abi)" '.assets[] | if (.name | test($ARCH)) then (.browser_download_url, .size) else empty end' 2> /dev/null)
[ "${#RESPONSE[@]}" -eq 0 ] && return 1
wget -q --show-progress "${RESPONSE[0]}" -O "$AAPT2"
chmod +x "$AAPT2"
if [ "${RESPONSE[1]}" == "$(stat -c %s "$AAPT2" 2> /dev/null)" ]; then
break
else
rm "$AAPT2"
fi
(( CTR++ ))
done
CTR=0 && while [ ! -e "$APK_EDITOR" ]; do
[ $CTR -gt 2 ] && return 1
echo -e "\nDownloading APKEditor...\n"
readarray -t RESPONSE < <(curl -s "https://api.github.com/repos/REAndroid/APKEditor/releases/latest" | jq -r '.assets[0] | .browser_download_url, .size' 2> /dev/null)
[ "${#RESPONSE[@]}" -eq 0 ] && return 1
wget -q --show-progress "${RESPONSE[0]}" -O "$APK_EDITOR"
if [ "${RESPONSE[1]}" == "$(stat -c %s "$APK_EDITOR" 2> /dev/null)" ]; then
break
else
rm "$APK_EDITOR"
yes | pkg uninstall -y openjdk-21
yes | pkg install openjdk-17
fi
(( CTR++ ))
done
return 0
}
fetchSrc() {
[ -e "$SRC/.info" ] && source "$SRC/.info"
[ "$INTERNET_ACCESS" == false ] && return
ping -c 1 google.com &> /dev/null || return
echo "Checking Latest Release..."
TAG=$(curl -s 'https://api.github.com/repos/decipher3114/Revancify/releases/latest' 2> /dev/null | jq -r '.tag_name')
[ "$TAG" == "$VERSION" ] && return
echo "Revancify $TAG is available..."
echo "Installing..."
wget -qc "https://github.com/decipher3114/Revancify/archive/refs/tags/$TAG.zip" -O "$TAG.zip"
if [ -e "$TAG.zip" ]; then
unzip -qo "$TAG.zip"
rm -rf "$TAG.zip"
for CONTENT in Revancify-*/* Revancify-*/.*; do
rm -rf "${SRC:?}/$(basename "$CONTENT")"
mv "$CONTENT" "$SRC/"
done
rm -rf Revancify-* &> /dev/null
cp -f "$SRC/revancify" "$PREFIX/bin/revancify"
chmod +x "$PREFIX/bin/revancify"
echo -e "Revancify $TAG is now installed.\nRun 'revancify -h' for help."
exit
else
echo -e "Unable to install Revancify $TAG !!\nPlease try again with proper Internet"
exit 1
fi
}
clear
if ! installDependencies; then
echo -e "Dependencies not installed !!\nRun again with stable internet connection."
exit 1
fi
fetchSrc
if [ "$ROOT_ACCESS" != false ] && su -c 'exit' &> /dev/null ; then
ROOT_ACCESS=true
else
ROOT_ACCESS=false
fi
cd "$SRC" &> /dev/null || terminate
bash main.sh "$ROOT_ACCESS"
EXIT_CODE=$?
exit "$EXIT_CODE"