-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcustomize.sh
More file actions
108 lines (94 loc) · 3.29 KB
/
Copy pathcustomize.sh
File metadata and controls
108 lines (94 loc) · 3.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
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
#!/system/bin/sh
# Auto-generated customize.sh script
SKIPUNZIP=1
DEFAULT_PATH="/data/adb/magisk"
extract() {
local filename=$1
local dst=$2
unzip -qo "$ZIPFILE" "$filename" -d "$dst"
}
# Root interface detection
KSUDIR="/data/adb/ksu"
APDIR="/data/adb/ap"
BUSYBOX="$DEFAULT_PATH/busybox"
KSU=false
AP=false
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
# Extract zygisk libraries
isZygisk=true
if $isZygisk; then
DEVICE_ABI="$(getprop ro.product.cpu.abi)"
if [ "$DEVICE_ABI" = "arm64-v8a" ] || [ "$DEVICE_ABI" = "armeabi-v7a" ] || [ "$DEVICE_ABI" = "x86_64" ] || [ "$DEVICE_ABI" = "x86" ]; then
extract "zygisk/$DEVICE_ABI.so" $MODPATH
else
abort "Unknown architecture: $DEVICE_ABI"
fi
fi
# Setup bash environment
INSTALLER="$TMPDIR/installer.sh"
ANDROID_TEMP_DIR="/data/local/tmp"
ANDROID_CACHE_DIR="/cache"
# Check for installer.sh in multiple locations
INSTALLER_FOUND_AT="$TMPDIR"
extract "installer.sh" $TMPDIR
if [ ! -f "$TMPDIR/installer.sh" ]; then
ui_print "Error: installer.sh not found. trying alternative path..."
extract "installer.sh" $ANDROID_TEMP_DIR
if [ ! -f "$ANDROID_TEMP_DIR/installer.sh" ]; then
ui_print "Error: installer.sh not found. trying alternative path..."
extract "installer.sh" $ANDROID_CACHE_DIR
if [ ! -f "$ANDROID_CACHE_DIR/installer.sh" ]; then
abort "Error: installer.sh not found. all attempts failed."
else
INSTALLER_FOUND_AT="$ANDROID_CACHE_DIR"
fi
else
INSTALLER_FOUND_AT="$ANDROID_TEMP_DIR"
fi
fi
# Update INSTALLER path based on where it was found
INSTALLER="$INSTALLER_FOUND_AT/installer.sh"
# Check for bin/$ARCH.xz in multiple locations
extract "bin/$ARCH.xz" $TMPDIR
FOUND_AT="$TMPDIR" # initial path
if [ ! -f "$TMPDIR/bin/$ARCH.xz" ]; then
ui_print "Error: required file is not found. trying alternative path..."
extract "bin/$ARCH.xz" $ANDROID_TEMP_DIR
if [ ! -f "$ANDROID_TEMP_DIR/bin/$ARCH.xz" ]; then
ui_print "Error: required file is not found. trying alternative path..."
extract "bin/$ARCH.xz" $ANDROID_CACHE_DIR
if [ ! -f "$ANDROID_CACHE_DIR/bin/$ARCH.xz" ]; then
abort "Error: required file is not found. all attempts failed."
else
FOUND_AT="$ANDROID_CACHE_DIR"
fi
else
FOUND_AT="$ANDROID_TEMP_DIR"
fi
fi
$BUSYBOX xz -d "$FOUND_AT/bin/$ARCH.xz"
mv "$FOUND_AT/bin/$ARCH" "$FOUND_AT/bin/bash"
# Setting up files permissions
chmod 755 "$FOUND_AT/bin/bash" || abort "Couldn't change -> $FOUND_AT/bin/bash permission"
chmod +x "$INSTALLER" || abort "Couldn't change -> $INSTALLER permission"
# Setup module environment
export KSUDIR APDIR AP MODID MODNAME MODAUTH OUTFD ABI API MAGISKBIN NVBASE BOOTMODE MAGISK_VER_CODE MAGISK_VER ZIPFILE MODPATH TMPDIR DEFAULT_PATH KSU ABI32 IS64BIT ARCH BMODID BUSYBOX
# bash executor
bashexe() {
$FOUND_AT/bin/bash "$@"
return $?
}
# Finally execute the installer
sed -i "1i\ " "$INSTALLER"
sed -i "1s|.*|#!$FOUND_AT/bin/bash|" $INSTALLER
if ! bashexe -c ". $DEFAULT_PATH/util_functions.sh; source $INSTALLER"; then
abort
fi