This repository was archived by the owner on Aug 17, 2024. It is now read-only.
forked from c3ph3us/HuskyDG_BootloopSaver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.sh
86 lines (63 loc) · 2.32 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
78
79
80
81
82
83
84
85
#!/system/bin/sh
#Bootloop saver by HuskyDG
MODULEDIR=${0%/*}
. "$MODULEDIR/utils.sh"
MAGISKTMP="$(magisk --path)"
[ -z "$MAGISKTMP" ] && MAGISKTMP=/sbin
post_fs_dir
MIRRORPROP="$MAGISKTMP/.magisk/modules/${MODULEDIR##*/}/module.prop"
TMPPROP="$MAGISKTMP/saver.prop"
cat "$MIRRORPROP" >"$TMPPROP"
rm -rf /data/adb/saver
ln -sf "$MAGISKTMP/.magisk/modules/${MODULEDIR##*/}" /data/adb/saver
[ -f "$POSTFSDIR/note.txt" ] && MESSAGE="$(cat "$POSTFSDIR/note.txt" | head -c100)"
if [ -f "$MAGISKTMP/bootloopsaver/module.prop" ]; then
sed -Ei "s/^description=(\[.*][[:space:]]*)?/description=[ ✔✔ Working with advanced functions. $MESSAGE ] /g" "$TMPPROP"
else
sed -Ei "s/^description=(\[.*][[:space:]]*)?/description=[ ✔ Working with basic functions. $MESSAGE ] /g" "$TMPPROP"
fi
mount --bind "$TMPPROP" "/data/adb/saver/module.prop"
rm -rf "$POSTFSDIR/bootloop_saver.log.bak"
mv -f "$POSTFSDIR/bootloop_saver.log" "$POSTFSDIR/bootloop_saver.log.bak" 2>/dev/null
write_log "bootloop saver started"
MAIN_ZYGOTE_NICENAME=zygote
CPU_ABI=$(getprop ro.product.cpu.api)
[ "$CPU_ABI" = "arm64-v8a" -o "$CPU_ABI" = "x86_64" ] && MAIN_ZYGOTE_NICENAME=zygote64
check(){
TEXT1="$1"
TEXT2="$2"
result=false
for i in $TEXT1; do
for j in $TEXT2; do
[ "$i" == "$j" ] && result=true
done
done
$result
}
# Wait for zygote starts
sleep 5
ZYGOTE_PID1=$(pidof "$MAIN_ZYGOTE_NICENAME")
write_log "pid of zygote stage 1: $ZYGOTE_PID1"
sleep 15
ZYGOTE_PID2=$(pidof "$MAIN_ZYGOTE_NICENAME")
write_log "pid of zygote stage 2: $ZYGOTE_PID2"
sleep 15
ZYGOTE_PID3=$(pidof "$MAIN_ZYGOTE_NICENAME")
write_log "pid of zygote stage 3: $ZYGOTE_PID3"
if check "$ZYGOTE_PID1" "$ZYGOTE_PID2" && check "$ZYGOTE_PID2" "$ZYGOTE_PID3"; then
if [ -z "$ZYGOTE_PID1" ]; then
write_log "maybe zygote not start :("
write_log "zygote meets the trouble, disable all modules and restart"
disable_modules
else
exit_log "pid of 3 stage zygote is the same"
fi
else
write_log "pid of 3 stage zygote is different, continue check to make sure... "
fi
sleep 15
ZYGOTE_PID4=$(pidof "$MAIN_ZYGOTE_NICENAME")
write_log "pid of zygote stage 4: $ZYGOTE_PID4"
check "$ZYGOTE_PID3" "$ZYGOTE_PID4" && exit_log "pid of zygote stage 3 and 4 is the same."
write_log "zygote meets the trouble, disable all modules and restart"
disable_modules