-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdater.sh
260 lines (222 loc) · 6.19 KB
/
updater.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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
#!/data/adb/modules/iUnlockerGL/iunlocker-sdk/bin/bash
##############################################
# Updater script by Taylo @ github.com/i-taylo
##############################################
set -eu
export SKIP_SYSTEM_SERVER=0
export CAPTURE_KEY="NjVmYmU3NmI3M2IyYTczYzhkYjk1MDIyNDhhNTQwODA4NzQyODE5NWFjOThkZjBlNTJhYzk5MmMx"
export MEMORY_SIGNAL_MAGIC='0xEE3F'
export __LDX__INIT__="onLilithLoad(global($MEMORY_SIGNAL_MAGIC).set(0)):close(global(S).set(0)):load(global(T).set(0)).commit();"
trap cleanup EXIT
function raise_error() {
local reason="$1"
local EXIT_FAILURE=1
# "Contain" the error message into the memory magic
echo -e "[[$MEMORY_SIGNAL_MAGIC]](\"$reason\")"
return $EXIT_FAILURE
}
function grep_prop() { # from util_functions.sh | magisk
local REGEX="s/^$1=//p"
shift
local FILES=$@
[ -z "$FILES" ] && FILES='/system/build.prop'
cat $FILES 2>/dev/null | dos2unix | sed -n "$REGEX" | head -n 1
}
function grep_get_prop() { # from util_functions.sh | magisk
local result=$(grep_prop $@)
if [ -z "$result" ]; then
# Fallback to getprop
getprop "$1"
else
echo $result
fi
}
function api_level_arch_detect() { # from util_functions.sh | magisk
API=$(grep_get_prop ro.build.version.sdk)
ABI=$(grep_get_prop ro.product.cpu.abi)
if [ "$ABI" = "x86" ]; then
ARCH=x86
ABI32=x86
IS64BIT=false
elif [ "$ABI" = "arm64-v8a" ]; then
ARCH=arm64
ABI32=armeabi-v7a
IS64BIT=true
elif [ "$ABI" = "x86_64" ]; then
ARCH=x64
ABI32=x86
IS64BIT=true
else
ARCH=arm
ABI=armeabi-v7a
ABI32=armeabi-v7a
IS64BIT=false
fi
}
function ensure_root() {
if [ $(id -u) != 0 ]; then
raise_error "device not rooted or root permissions were denied"
fi
}
function check_arch() { # Not needed anymore
arch="$(uname -m)"
if [ "$arch" != "aarch64" ]; then
raise_error "Unsupported architecture: $arch"
fi
}
function spr() {
local message="$1"
local NO_IGNORE_ON_PRINT="001"
echo -e "[[$MEMORY_SIGNAL_MAGIC$NO_IGNORE_ON_PRINT]](\"$message\")"
}
function create_tmpdir() {
if mkdir -p $1; then
spr "Successfully created: ${1##*/}"
else
raise_error "Couldn't create tmpdir"
fi
}
function cleanup() {
APP_DATA="/data/data/com.TayloIUnlockerGL"
if [ -f "$APP_DATA/expired" ]; then
if rm $APP_DATA/expired; then
spr "Successfully removed: $APP_DATA/expired"
fi
fi
if rm -rf "$MODULETMPDIR" "$MODULETMPDIR/MODULES"; then
spr "Successfully cleanup"
fi
}
function download() {
local url output opts MAX_ATTEMPTS ATTEMPT
url="$2"
output="$1"
opts='--no-check-certificate -e robots=off -q -O'
mkdir -p "$(dirname "$output")"
MAX_ATTEMPTS=5
ATTEMPT=1
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
if /data/adb/modules/iUnlockerGL/iunlocker-sdk/bin/wget $opts "$output" "$url"; then
spr "Successfully downloaded: $output"
return 0
else
spr "Couldn't download $output from: $url, retrying..."
fi
ATTEMPT=$((ATTEMPT + 1))
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
spr "Reached maximum retries."
return 1 # will be handled later
fi
done
}
function cpy() {
local target=$1
local dest=$2
if cp -af "$target" "$dest"; then
spr "Successfully copied ${target##*/} -> $dest"
else
raise_error "Couldn't copy important file"
fi
}
ebusybox() {
$BUSYBOX "$@"
return $?
}
BASE="/data/adb/modules/iUnlockerGL"
SDKDIR="$BASE/iunlocker-sdk"
ZYGISK_LIBRARY="$BASE/zygisk"
REPO_NAME="iUnlockerGL"
ME="i-Taylo"
URL="https://raw.githubusercontent.com/$ME/$REPO_NAME/refs/heads/main"
FILES_ARRAY_URL="https://raw.githubusercontent.com/$ME/$REPO_NAME/refs/heads/main/MODULES"
MODULETMPDIR="$BASE/moduletmp"
DEFAULT_PATH="/data/adb/magisk"
KSUDIR="/data/adb/ksu"
APDIR="/data/adb/ap"
KSU=false
AP=false
BUSYBOX="$DEFAULT_PATH/busybox"
api_level_arch_detect
ensure_root
if [ -f "$KSUDIR/bin/busybox" ]; then
KSU=true
DEFAULT_PATH=$KSUDIR
BUSYBOX="$DEFAULT_PATH/bin/busybox"
elif [ -f "$APDIR/bin/busybox" ]; then
AP=true
DEFAULT_PATH="$APDIR"
BUSYBOX="$DEFAULT_PATH/bin/busybox"
fi
if [ ! -d "$BASE" ]; then
raise_error "MODULE DIRECTORY NOT EXISTS"
fi # End of check->$BASE
if [ ! -d "$SDKDIR" ]; then
raise_error "iUnlocker SDK DIRECTORY NOT EXISTS"
fi # End of check->$SDKDIR
create_tmpdir "$MODULETMPDIR"
cd "$MODULETMPDIR" # enter tmpdir
# Let's delete "${FILES_ARRAY_URL##*/}" before downloading fresh file
if [ -f "${FILES_ARRAY_URL##*/}" ]; then
if rm "${FILES_ARRAY_URL##*/}"; then
spr "Deleted: "${FILES_ARRAY_URL##*/}""
fi
fi # end of deletion
# Now let's download fresh one.
if ! download "${FILES_ARRAY_URL##*/}" "$FILES_ARRAY_URL"; then
raise_error "error downloading important file"
fi # end of downloading
#
dos2unix "${FILES_ARRAY_URL##*/}"
MODULES_FILE="$(cat ${FILES_ARRAY_URL##*/})"
for file in ${MODULES_FILE[@]}; do
if ! download "./$file" "$URL/$file"; then
raise_error "error downloading important file"
fi
done
# Reached to this point now let's move everything to maindir
mode=755
cd $BASE # go back
if cp -af "$MODULETMPDIR/"* "$BASE"; then
if cp -af "$SDKDIR/tools/lib/$ARCH/"* "$SDKDIR/lib"; then
spr "Successfully copied: $SDKDIR/tools/lib/$ARCH -> $SDKDIR/lib"
else
raise_error "Couldn't copy important libraries"
fi
if cp -af "$SDKDIR/tools/$ARCH/"* "$SDKDIR/bin"; then
spr "Successfully copied: $SDKDIR/tools/$ARCH -> $SDKDIR/bin"
else
raise_error "Couldn't copy important binaries!!!"
fi
if rm -rf $SDKDIR/tools; then
spr "Removed: $SDKDIR/tools"
fi
cd $BASE/bin # enter bin
if ebusybox xz -d $ARCH.xz; then
spr "Successfully extracted: $ARCH.xz"
else
raise_error "Couldn't extract important binary!!!"
fi
if mv $ARCH bash; then
spr "Successfully renamed $ARCH -> bash"
else
raise_error "Couldn't rename $ARCH->bash !!! operation required"
fi
if mv bash $BASE/iunlocker-sdk/bin; then
spr "Successfully moved bash -> $BASE/iunlocker-sdk/bin"
else
raise_error "Couldn't move bash to iunlocker sdk!!! it's required"
fi
cd .. # getting back
if rm -rf $BASE/bin; then
spr "Removed $BASE/bin"
fi
# Reached to this point
spr "Successfully moved all files"
if chmod -R $mode $BASE; then
spr "Successfully changed permissions"
else
raise_error "Couldn't change permission!! libraries & binaries cannot run without proper permissions!!!"
fi
else
raise_error "Couldn't move important files"
fi