-
Notifications
You must be signed in to change notification settings - Fork 4
/
service.sh
77 lines (63 loc) · 1.71 KB
/
service.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
#!/data/adb/magisk/busybox sh
#Bootloop saver by HuskyDG, modified by ez-me
# Get variables
MODPATH=${0%/*}
MESSAGE="$(cat "$MODPATH"/msg.txt | head -c100)"
# Log
log(){
TEXT=$@; echo "[`date -Is`]: $TEXT" >> $MODPATH/log.txt
}
log "Started"
# Modify description
cp "$MODPATH/module.prop" "$MODPATH/temp.prop"
sed -Ei "s/^description=(\[.*][[:space:]]*)?/description=[Working. $MESSAGE] /g" "$MODPATH/temp.prop"
mv "$MODPATH/temp.prop" "$MODPATH/module.prop"
# Define the function
disable_modules(){
log "Disabling modules..."
list="$(find /data/adb/modules/* -prune -type d)"
for module in $list
do
touch $module/disable
done
rm -rf "$MODPATH/disable"
echo "Disabled modules at $(date -Is)" > "$MODPATH/msg.txt"
rm -rf /cache/.system_booting /data/unencrypted/.system_booting /metadata/.system_booting /persist/.system_booting /mnt/vendor/persist/.system_booting
log "Rebooting"
log ""
reboot
exit
}
# Gather PIDs
sleep 5
ZYGOTE_PID1=$(getprop init.svc_debug_pid.zygote)
log "PID1: $ZYGOTE_PID1"
sleep 15
ZYGOTE_PID2=$(getprop init.svc_debug_pid.zygote)
log "PID2: $ZYGOTE_PID2"
sleep 15
ZYGOTE_PID3=$(getprop init.svc_debug_pid.zygote)
log "PID3: $ZYGOTE_PID3"
# Check for BootLoop
log "Checking..."
if [ -z "$ZYGOTE_PID1" ]
then
log "Zygote didn't start?"
disable_modules
fi
if [ "$ZYGOTE_PID1" != "$ZYGOTE_PID2" -o "$ZYGOTE_PID2" != "$ZYGOTE_PID3" ]
then
log "PID mismatch, checking again"
sleep 15
ZYGOTE_PID4=$(getprop init.svc_debug_pid.zygote)
log "PID4: $ZYGOTE_PID4"
if [ "$ZYGOTE_PID3" != "$ZYGOTE_PID4" ]
then
log "They don't match..."
disable_modules
fi
fi
# If we reached this section we should be fine
log "looks good to me!"
log ""
exit