-
Notifications
You must be signed in to change notification settings - Fork 60
/
revancify
executable file
·170 lines (159 loc) · 5.92 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
#!/usr/bin/bash
HOME=/data/data/com.termux/files/home
BIN=/data/data/com.termux/files/usr/bin
repo="$HOME/Revancify"
cp "$repo/revancify" "$BIN/revancify" >/dev/null 2>&1
root=default
online="Checking..."
DATA="$HOME/revancify-data"
[ ! -d $DATA ] && mkdir -p "$DATA"
# shellcheck source=/dev/null
source "$DATA/config.cfg" > /dev/null 2>&1
[ "${LightTheme:-false}" == "true" ] && theme=Light || theme=Dark
export DIALOGRC="$repo/configs/.dialogrc$theme"
help() {
if [ "$1" == "1" ]; then
readarray -t invalidArgs < <(for i in "${FLAG_ERR[@]}"; do
if grep -q "unrecognized" <<< "$i"; then
grep -oP "(?<=\`).*(?=')" <<< "$i"
else
cut -b 27 <<< "$i" | xargs -0 -I {} echo -n "-{}"
fi
done)
IFS=","
echo -e "\e[1;31mInvalid Argument(s) Passed: ${invalidArgs[*]}\n"
fi
echo -e "revancify\n
Usage: revancify [OPTION]\n
Options:
-n, --no-root Run without SU permissions
-o, --offline Run without updating revancify
-r, --reinstall Reinstall revancify
-h, --help Prints help statement"
exit "$1"
}
if ! ARGS=$(getopt -o nohr -l "no-root,offline,help,reinstall" -- "$@" 2>/dev/null); then
readarray -t FLAG_ERR < <(getopt -o nohr -l no-root,offline,help,reinstall -- "$@" 2>&1 1>&-)
help 1
fi
eval set -- "$ARGS"
while [ $# -gt 0 ]
do
case "$1" in
"-h" | "--help")
help 0
;;
"-n" | "--no-root")
root=false
shift
;;
"-r" | "--reinstall")
if ping -c 1 google.com >/dev/null 2>&1; then
rm -rf $DATA
cd "$repo"/.. && rm -rf "$repo" && git clone --depth=1 https://github.com/decipher3114/Revancify.git && "$repo/revancify" && exit
else
echo "No internet Connection !!"
exit 1
fi
;;
"-o" | "--offline")
online=false
shift
;;
"--")
shift
break
;;
esac
shift
done
terminate() {
clear
echo "Script terminated !!"
tput cnorm
exit 1
}
trap terminate SIGTERM SIGINT SIGABRT
checkdependencies() {
if [ -e "$DATA/aapt2" ] && [ -e "$DATA/ApkEditor.jar" ] && bins=$(ls "$BIN") && grep -q java <<<"$bins" && grep -q wget <<<"$bins" && grep -q tput <<<"$bins" && grep -q dialog <<<"$bins" && grep -q pup <<<"$bins" && grep -q jq <<<"$bins" && grep -q unzip <<<"$bins" && ls "$BIN/revancify" >/dev/null 2>&1 && ls "$HOME/storage" >/dev/null 2>&1; then
return 0
else
if ping -c 1 google.com >/dev/null 2>&1; then
installdependencies || (echo "Dependencies not installed !!" && exit 1)
else
cp "$repo/revancify" "$BIN/revancify"
echo -e "Dependencies not installed !!\nRun again with internet connection."
exit 1
fi
fi
}
installdependencies() {
clear
echo "Installing dependencies..."
arch=$(getprop ro.product.cpu.abi)
cp "$repo/revancify" "$BIN/revancify"
sleep 1
[ ! -d "$HOME/storage" ] && termux-setup-storage
pkg update -y -o Dpkg::Options::="--force-confnew" || return 1
pkg install openjdk-17 wget ncurses-utils dialog pup jq -y -o Dpkg::Options::="--force-confnew" || return 1
git config --global pull.rebase true
sed -i '/allow-external-apps/s/# //' "$HOME/.termux/termux.properties"
[ ! -f "$DATA/aapt2" ] && wget "https://github.com/decipher3114/binaries/releases/latest/download/aapt2_$arch" -O "$DATA/aapt2" && chmod +x "$DATA/aapt2"
[ ! -e "$DATA/ApkEditor.jar" ] && wget "$(curl -s "https://api.github.com/repos/REAndroid/APKEditor/releases/latest" | jq -r '.assets[0].browser_download_url')" -O "$DATA/ApkEditor.jar"
echo "Dependencies installed successfully."
return 0
}
checkrevancify() {
if [ -d "$repo" ]; then
cd "$repo" >/dev/null 2>&1 || true
rm -rf ./*cache*
return 0
else
echo -e "\e[1;31mRevancify dir is not found !!"
echo -e "\e[1;31mDo you want to reinstall Revancify?"
read -r -p "[Y/N]: " choice
case "$choice" in
y | Y)
rm -rf "$repo"
git clone --depth=1 https://github.com/decipher3114/Revancify.git && $repo/revancify && exit
;;
n | N)
echo "Removing revancify completely !!"
sleep 0.5s
rm "$BIN/revancify"
echo "Successfully Uninstalled revancify."
exit 0
;;
?)
echo "Invalid option !!"
exit 1
;;
esac
fi
}
checkdependencies
checkrevancify
tput civis
dialog --no-shadow --infobox "\n █▀█ █▀▀ █░█ ▄▀█ █▄░█ █▀▀ █ █▀▀ █▄█\n █▀▄ ██▄ ▀▄▀ █▀█ █░▀█ █▄▄ █ █▀░ ░█░ \n\nDeveloper : decipher\nLast Updated : Checking...\nOnline : $online" 10 42
if [ "$online" != false ]; then
ping -c 1 google.com >/dev/null 2>&1 && online=true || online=false
fi
if [ "$online" == true ]; then
if ! git pull >/dev/null 2>&1;then
git fetch --all >/dev/null 2>&1 &&\
git reset --hard "@{u}" >/dev/null 2>&1
fi
fi
dialog --no-shadow --infobox "\n █▀█ █▀▀ █░█ ▄▀█ █▄░█ █▀▀ █ █▀▀ █▄█\n █▀▄ ██▄ ▀▄▀ █▀█ █░▀█ █▄▄ █ █▀░ ░█░ \n\nDeveloper : decipher\nLast Updated : $(git log -1 --pretty='format:%cd' --date=format:'%b %d, %Y | %H:%M')\nOnline : $online" 10 42
cd "$DATA" >/dev/null 2>&1 || true
bash "$repo/main.sh" "$root" "$online"
exitstatus=$?
clear
cd "$HOME" || :
if [ $exitstatus -eq 0 ]; then
echo "Script exited !!"
else
echo "Script terminated !!"
rm -rf -- *cache >/dev/null 2>&1
fi
tput cnorm