-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathaction.sh
More file actions
254 lines (211 loc) · 7.45 KB
/
action.sh
File metadata and controls
254 lines (211 loc) · 7.45 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/system/bin/busybox sh
MODPATH="${0%/*}"
# If MODPATH is empty or is not default modules path, use current path
[ -z "$MODPATH" ] || ! echo "$MODPATH" | grep -q '/data/adb/modules/' &&
MODPATH="$(dirname "$(readlink -f "$0")")"
# Fallback for ui_print if not defined
type ui_print >/dev/null 2>&1 || ui_print() { echo "$@"; }
# Using util_functions.sh
[ -f "$MODPATH/util_functions.sh" ] && . "$MODPATH/util_functions.sh" || { ui_print "! util_functions.sh not found!"; exit 1; }
# Determine current cron status
get_cron_status() {
if [ -f "$MODPATH/disable_cron" ]; then
echo "Always Disabled"
elif [ -f "$MODPATH/disable_cron_temp" ]; then
echo "Disabled until Reboot"
else
# config.prop fallback
_cron_cfg=$(grep -s '^propscleaner_cron=' "$MODPATH/config.prop" | cut -d= -f2)
if boolval "$_cron_cfg"; then
echo "Enabled"
else
echo "Always Disabled"
fi
fi
}
update_description() {
_cron_status=$(get_cron_status)
case "$_cron_status" in
"Enabled") _cron_tag="[✅ Custom ROM spoofing," ;;
"Disabled until Reboot") _cron_tag="[⏸️ Custom ROM spoofing," ;;
*) _cron_tag="[❌ Custom ROM spoofing," ;;
esac
_rs_cfg=$(grep -s '^download_resetprop_rs=' "$MODPATH/config.prop" | cut -d= -f2)
if boolval "$_rs_cfg"; then
_rs_tag="✅ resetprop-rs]"
else
_rs_tag="❌ resetprop-rs]"
fi
set_description "$_cron_tag $_rs_tag"
restore_desc_if_needed
}
# Detect device architecture for resetprop-rs
RESETPROP_RS_URL="https://github.com/Enginex0/resetprop-rs/releases/latest/download"
_arch=$(uname -m 2>/dev/null)
case "$_arch" in
aarch64*) RESETPROP_RS_ASSET="resetprop-arm64-v8a" ;;
armv7*|armv8l) RESETPROP_RS_ASSET="resetprop-armeabi-v7a" ;;
*) RESETPROP_RS_ASSET="" ;;
esac
# Crontabs config
CURRENT=$(get_cron_status)
ui_print ""
ui_print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
ui_print " Custom ROM Spoofing Configuration"
ui_print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
ui_print ""
ui_print " Current status: $CURRENT"
ui_print ""
ui_print " [Vol+] Enable"
ui_print " [Vol-] Disable options"
ui_print ""
ui_print " Waiting for input (15s timeout)..."
ui_print ""
vol_key_wait 15
if [ "$VOL_RESULT" = "up" ]; then
# Enable
rm -f "$MODPATH/disable_cron" "$MODPATH/disable_cron_temp"
# Override config.prop
sed -i "s|^propscleaner_cron=.*|propscleaner_cron=true|" "$MODPATH/config.prop"
# Start immediately
sh "$MODPATH/propscleaner.sh" &
[ ! -f "$MODPATH/crontabs/root" ] && {
mkdir -p "$MODPATH/crontabs"
echo "30 * * * * sh $MODPATH/propscleaner.sh > /dev/null 2>&1 &" | busybox crontab -c "$MODPATH/crontabs" -
}
[ -d "$MODPATH/crontabs" ] && busybox crond -bc "$MODPATH/crontabs" -L /dev/null > /dev/null 2>&1 &
ui_print " ✅ Custom ROM spoofing ENABLED"
ui_print ""
elif [ "$VOL_RESULT" = "down" ]; then
# Show disable sub-menu
ui_print ""
ui_print " Choose disable mode:"
ui_print ""
ui_print " [Vol+] Disable until Reboot"
ui_print " [Vol-] Always Disable"
ui_print ""
ui_print " Waiting for input (15s timeout)..."
ui_print ""
vol_key_wait 15
# Stop crond and remove crontab
busybox pkill -f "crond -bc $MODPATH/crontabs" 2>/dev/null
rm -rf "$MODPATH/crontabs"
if [ "$VOL_RESULT" = "up" ]; then
# Disable until Reboot
if [ "$CURRENT" == "Always Disabled" ]; then
rm -f "$MODPATH/disable_cron"
fi
touch "$MODPATH/disable_cron_temp"
# Override config.prop
sed -i "s|^propscleaner_cron=.*|propscleaner_cron=true|" "$MODPATH/config.prop"
ui_print " ⏸️ Custom ROM spoofing DISABLED until Reboot"
ui_print ""
elif [ "$VOL_RESULT" = "down" ]; then
# Always Disable
if [ "$CURRENT" == "Disabled until Reboot" ]; then
rm -f "$MODPATH/disable_cron_temp"
fi
touch "$MODPATH/disable_cron"
# Override config.prop
sed -i "s|^propscleaner_cron=.*|propscleaner_cron=false|" "$MODPATH/config.prop"
ui_print " ❌ Custom ROM spoofing ALWAYS DISABLED"
ui_print ""
else
# Timeout
ui_print " No input received. No changes made."
ui_print " Current status remains: $CURRENT"
ui_print ""
fi
else
# Timeout
ui_print " No input received. No changes made."
ui_print " Current status remains: $CURRENT"
ui_print ""
fi
ui_print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
ui_print ""
# resetprop-rs config
if [ -n "$RESETPROP_RS_ASSET" ]; then
if boolval "$_rs_cfg"; then
_rs_status="Installed"
else
_rs_status="Not installed"
fi
ui_print ""
ui_print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
ui_print " resetprop-rs Configuration"
ui_print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
ui_print ""
ui_print " Current status: $_rs_status"
ui_print ""
if [ "$_rs_status" = "Installed" ]; then
ui_print " [Vol+] Keep installed"
ui_print " [Vol-] Remove"
else
ui_print " [Vol+] Download & Install"
ui_print " [Vol-] Skip"
fi
ui_print ""
ui_print " Waiting for input (15s timeout)..."
ui_print ""
vol_key_wait 15
if [ "$_rs_status" = "Installed" ]; then
# Currently installed
if [ "$VOL_RESULT" = "down" ]; then
rm -f "$MODPATH/resetprop-rs"
# Override config.prop
sed -i "s|^download_resetprop_rs=.*|download_resetprop_rs=false|" "$MODPATH/config.prop"
ui_print " 🗑️ resetprop-rs REMOVED"
ui_print ""
elif [ "$VOL_RESULT" = "up" ]; then
ui_print " resetprop-rs kept."
ui_print ""
else
# Timeout
ui_print " No input received. No changes made."
ui_print " Current status remains: $_rs_status"
ui_print ""
fi
else
# Not installed
if [ "$VOL_RESULT" = "up" ]; 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"
ui_print ""
else
rm -f "$MODPATH/resetprop-rs"
ui_print " ! resetprop-rs binary failed smoke test, removing"
ui_print ""
_dl_ok=false
fi
else
rm -f "$MODPATH/resetprop-rs"
ui_print " ! Download failed"
ui_print ""
fi
elif [ "$VOL_RESULT" = "down" ]; then
ui_print " Skipped resetprop-rs."
ui_print ""
_dl_ok=false
else
# Timeout
ui_print " No input received. No changes made."
ui_print " Current status remains: $_rs_status"
ui_print ""
fi
# Override config.prop
sed -i "s|^download_resetprop_rs=.*|download_resetprop_rs=$_dl_ok|" "$MODPATH/config.prop"
fi
ui_print "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
ui_print ""
fi
update_description