This repository has been 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
/
utils.sh
66 lines (54 loc) · 1.78 KB
/
utils.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
FILE="$0"; NAME="$1"; VALUE="$2"; MODID="/data/adb/modules/huskydg_bootloopsaver"; VX="$@"
MODULEDIR=${0%/*}
MAGISKTMP="$(magisk --path)"
abort(){ echo "$1"; exit 1; }
post_fs_dir(){
unset POSTFSDIR
if [ -d /data/unencrypted ] && ! grep ' /data ' /proc/mounts | grep -qE 'dm-|f2fs'; then
POSTFSDIR="/data/unencrypted/${MODULEDIR##*/}"
elif grep ' /cache ' /proc/mounts | grep -q 'ext4' ; then
POSTFSDIR="/cache/${MODULEDIR##*/}"
elif grep ' /metadata ' /proc/mounts | grep -q 'ext4' ; then
POSTFSDIR="/metadata/${MODULEDIR##*/}"
elif grep ' /persist ' /proc/mounts | grep -q 'ext4' ; then
POSTFSDIR="/persist/${MODULEDIR##*/}"
elif grep ' /mnt/vendor/persist ' /proc/mounts | grep -q 'ext4' ; then
POSTFSDIR="/mnt/vendor/persist/${MODULEDIR##*/}"
elif [ ! -z "$MAGISKTMP" ]; then
POSTFSDIR="$MAGISKTMP/.magisk/${MODULEDIR##*/}"
else
POSTFSDIR="/dev/${MODULEDIR##*/}"
fi
[ ! -z "$POSTFSDIR" ] && mkdir -p "$POSTFSDIR"
}
post_fs_dir
write_log(){
TEXT=$@; echo "[`date +%d%m%y` `date +%T`]: $TEXT" >>"$POSTFSDIR/bootloop_saver.log"
}
exit_log(){
write_log "$@"; exit 0;
}
grep_prop() {
local REGEX="s/^$1=//p"
shift
local FILES=$@
[ -z "$FILES" ] && FILES='/system/build.prop'
cat $FILES 2>/dev/null | dos2unix | sed -n "$REGEX" | head -n 1
}
disable_modules(){
COUNT=0
list="$(find /data/adb/modules/* -prune -type d)"
IFS=$"
"
for module in $list; do
COUNT="$(($COUNT+1))"
echo -n >> $module/disable
done
## Disable all modules except itself
rm -rf "$MODULEDIR/disable"
COUNT="$(($COUNT-1))"
echo "I disabled $COUNT modules at `date +%d.%m.%y` `date +%T`" >"$POSTFSDIR/note.txt"
rm -rf /cache/.system_booting /data/unencrypted/.system_booting /metadata/.system_booting /persist/.system_booting /mnt/vendor/persist/.system_booting
reboot
exit
}