-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathcustomize.sh
More file actions
240 lines (203 loc) · 7.95 KB
/
customize.sh
File metadata and controls
240 lines (203 loc) · 7.95 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
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
#!/system/bin/busybox sh
# Define the path of root manager applet bin directories using find and set it to $PATH then export it
if ! command -v busybox >/dev/null 2>&1; then
TOYS_PATH=$(find "/data/adb" -maxdepth 3 \( -name busybox -o -name ksu_sus \) -exec dirname {} \; | sort -u | tr '\n' ':')
export PATH="${PATH:+${PATH}:}${TOYS_PATH%:}"
fi
enforce_install_from_app() {
if ! $BOOTMODE; then
ui_print "****************************************************"
ui_print "! Install from Recovery is NOT supported !"
ui_print "! Please install from Magisk / KernelSU / APatch !"
abort "****************************************************"
fi
}
check_magisk_version() {
ui_print "- Magisk version: $MAGISK_VER_CODE"
if [ "$MAGISK_VER_CODE" -lt 26302 ]; then
ui_print "******************************************"
ui_print "! Please install Magisk v26.3+ (26302+) !"
abort "******************************************"
fi
}
check_ksu_version() {
# Handle empty variables gracefully
KSU_KERNEL_VER_CODE=${KSU_KERNEL_VER_CODE:-0}
KSU_VER_CODE=${KSU_VER_CODE:-0}
ui_print "- KernelSU version: $KSU_KERNEL_VER_CODE (kernel) + $KSU_VER_CODE (ksud)"
# KernelSU Next detection (version 32000+ indicates Next, mainline is ~10000-12000)
if [ "$KSU_KERNEL_VER_CODE" -ge 32000 ] && [ "$KSU_KERNEL_VER_CODE" -lt 40000 ]; then
ui_print "- Detected KernelSU Next variant"
if [ "$KSU_KERNEL_VER_CODE" -lt 32000 ] || [ "$KSU_VER_CODE" -lt 32000 ]; then
ui_print "**********************************************"
ui_print "! KernelSU Next version is too old !"
abort "**********************************************"
fi
# Skip mainline checks for KernelSU Next
return 0
fi
# Mainline KernelSU checks
if [ "$KSU_KERNEL_VER_CODE" -lt 10940 ]; then
ui_print "**********************************************"
ui_print "! KernelSU version is too old !"
ui_print "! Please update KernelSU to latest version !"
abort "**********************************************"
elif [ "$KSU_KERNEL_VER_CODE" -ge 40000 ]; then
ui_print "*****************************************************"
ui_print "! KernelSU version abnormal !"
ui_print "! Please integrate KernelSU into your kernel !"
ui_print "! as submodule instead of copying the source code !"
abort "*****************************************************"
fi
if [ "$KSU_VER_CODE" -lt 10942 ]; then
ui_print "******************************************************"
ui_print "! ksud version is too old !"
ui_print "! Please update KernelSU Manager to latest version !"
abort "******************************************************"
fi
}
check_zygisksu_version() {
# Check for Zygisksu
if [ -f /data/adb/modules/zygisksu/module.prop ]; then
USES_ZYGISKSU=1
ZYGISKSU_VERSION=$(grep versionCode /data/adb/modules/zygisksu/module.prop | sed 's/versionCode=//g')
ui_print "- Zygisksu version: $ZYGISKSU_VERSION"
fi
# Check for ReZygisk
if [ -f /data/adb/modules/rezygisk/module.prop ]; then
USES_REZYGISK=1
REZYGISK_VERSION=$(grep versionCode /data/adb/modules/rezygisk/module.prop | sed 's/versionCode=//g')
ui_print "- ReZygisk version: $REZYGISK_VERSION"
fi
# Validate Zygisksu version
if [ -n "$USES_ZYGISKSU" ]; then
if [ -z "$ZYGISKSU_VERSION" ] || [ "$ZYGISKSU_VERSION" -lt 106 ]; then
ui_print "**********************************************"
ui_print "! Zygisksu version is too old !"
ui_print "! Please update Zygisksu to latest version !"
abort "**********************************************"
fi
fi
# Validate ReZygisk version
if [ -n "$USES_REZYGISK" ]; then
if [ -z "$REZYGISK_VERSION" ] || [ "$REZYGISK_VERSION" -lt 350 ]; then
ui_print "**********************************************"
ui_print "! ReZygisk version is too old !"
ui_print "! Please update ReZygisk to latest version !"
abort "**********************************************"
fi
fi
# Check if neither is installed
if [[ -z "$USES_ZYGISKSU" ]] && [[ -z "$USES_REZYGISK" ]]; then
ui_print "**********************************************"
ui_print "! Neither Zygisk nor ReZygisk found !"
abort "**********************************************"
fi
}
enforce_install_from_app
if [ "$KSU" ]; then
check_ksu_version
# check_zygisksu_version
else
check_magisk_version
fi
# Check architecture
if [ "$ARCH" != "arm" ] && [ "$ARCH" != "arm64" ] && [ "$ARCH" != "x86" ] && [ "$ARCH" != "x64" ]; then
abort "! Unsupported platform: $ARCH"
else
ui_print "- Device platform: $ARCH"
fi
if [ "$API" -lt 29 ]; then
abort "! Only support Android 10+ devices"
fi
# Using util_functions.sh
[ -f "$MODPATH/util_functions.sh" ] && . "$MODPATH/util_functions.sh" || abort "! util_functions.sh not found!"
# Backup original module.prop for status updates
[ -f "$PROP_FILE" ] && cp -f "$PROP_FILE" "$PROP_BAK"
# Optional Custom ROM hexpatching
_cron_cfg=$(grep -s '^propscleaner_cron=' "$MODPATH/config.prop" | cut -d= -f2)
ui_print ""
ui_print "- Enable periodic Custom ROMs props spoofing?"
ui_print " Vol+ = Enable | Vol- = Disable (15s timeout)"
vol_key_wait 15
CRON_ENABLED=""
case "$VOL_RESULT" in
up) CRON_ENABLED=true ;;
down) CRON_ENABLED=false ;;
esac
# Timeout — fall back to config.prop
if [ -z "$CRON_ENABLED" ]; then
if boolval "$_cron_cfg"; then
CRON_ENABLED=true
else
CRON_ENABLED=false
fi
fi
if boolval "$CRON_ENABLED"; then
rm -f "$MODPATH/disable_cron" "$MODPATH/disable_cron_temp"
ui_print "- Custom ROM spoofing enabled"
else
touch "$MODPATH/disable_cron"
ui_print "- Custom ROM spoofing disabled"
fi
# Override config.prop
sed -i "s|^propscleaner_cron=.*|propscleaner_cron=$CRON_ENABLED|" "$MODPATH/config.prop"
# Optional resetprop-rs download
RESETPROP_RS_URL="https://github.com/Enginex0/resetprop-rs/releases/latest/download"
case "$ARCH" in
arm64) RESETPROP_RS_ASSET="resetprop-arm64-v8a" ;;
arm) RESETPROP_RS_ASSET="resetprop-armeabi-v7a" ;;
*) RESETPROP_RS_ASSET="" ;;
esac
if [ -n "$RESETPROP_RS_ASSET" ]; then
# Read config.prop default value
_rs_cfg=$(grep -s '^download_resetprop_rs=' "$MODPATH/config.prop" | cut -d= -f2)
ui_print ""
ui_print "- Download resetprop-rs for enhanced stealth hexpatch?"
ui_print " Vol+ = Download | Vol- = Skip (15s timeout)"
vol_key_wait 15
DO_DOWNLOAD=""
case "$VOL_RESULT" in
up) DO_DOWNLOAD=true ;;
down) DO_DOWNLOAD=false ;;
esac
# Timeout — fall back to config.prop
if [ -z "$DO_DOWNLOAD" ]; then
if boolval "$_rs_cfg"; then
DO_DOWNLOAD=true
else
DO_DOWNLOAD=false
fi
fi
if boolval "$DO_DOWNLOAD"; then
ui_print "- Downloading resetprop-rs ($RESETPROP_RS_ASSET)..."
if wget -qO "$MODPATH/resetprop-rs" "$RESETPROP_RS_URL/$RESETPROP_RS_ASSET" 2>/dev/null || \
curl -sLo "$MODPATH/resetprop-rs" "$RESETPROP_RS_URL/$RESETPROP_RS_ASSET" 2>/dev/null; then
_dl_ok=true
else
_dl_ok=false
fi
if boolval "$_dl_ok"; then
chmod 755 "$MODPATH/resetprop-rs"
if "$MODPATH/resetprop-rs" -h >/dev/null 2>&1; then
ui_print "- resetprop-rs installed successfully"
else
ui_print "! resetprop-rs binary failed smoke test, removing"
rm -f "$MODPATH/resetprop-rs"
DO_DOWNLOAD=false
fi
else
ui_print "! Download failed, falling back to built-in hexpatch"
rm -f "$MODPATH/resetprop-rs"
DO_DOWNLOAD=false
fi
else
ui_print "- Skipping resetprop-rs, using built-in hexpatch"
fi
# Override config.prop
sed -i "s|^download_resetprop_rs=.*|download_resetprop_rs=$DO_DOWNLOAD|" "$MODPATH/config.prop"
fi
# Set Module permissions
set_perm_recursive "$MODPATH" 0 0 0755 0644
[ -f "$MODPATH/resetprop-rs" ] && chmod 755 "$MODPATH/resetprop-rs"
ui_print "? Please uninstall this module before dirty-flashing/updating the ROM."