Skip to content

Commit 0d33394

Browse files
author
Takeda-senpai
committed
add patch boot image
1 parent 9e45319 commit 0d33394

File tree

6 files changed

+68
-14
lines changed

6 files changed

+68
-14
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Magisk BootloopSaver
22

3-
> WARNING: Most of bootloop can be prevented but not completely. The script can be killed by other process, another module or broken Magisk.
4-
53
## About
64
Protect your system from bootloop caused by Magisk modules. In case the data partition is encrypted and you cannot access `/data/adb/modules`, or you don't want to turn off **force encryption** to protect your private data.
75

@@ -19,7 +17,7 @@ Usually, bootloop occurs because zygote doesn't start properly or stuck at resta
1917
### Disable from Custom Recovery
2018

2119

22-
You can boot into **TWRP** and create a dummy file named `disable_magisk` in one of these location to tell the script disable all modules and reboot your device (if **Auto detect** is not working):
20+
You can boot into **TWRP** and create a dummy file named `disable_magisk` in one of these location and then reboot to system to boot into Safe Mode (if **Auto detect** is not working):
2321
- /cache
2422
- /data/unencrypted
2523
- /metadata

changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
### v1.5
2-
- Fix incorrect detection in case there are multiple zygote proccesses
1+
### v1.6
2+
- Add patch into boot image that allows you to trigger Safe Mode by using Custom Recovery

customize.sh

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,45 @@
1-
ui_print "- Set up module..."
2-
unzip -o "$ZIPFILE" "saver.exec" -d "$MODPATH" &>/dev/null
3-
chmod 750 "$MODPATH/saver.exec"
1+
MAGISKTMP="$(magisk --path)"
2+
get_flags
3+
find_boot_image
4+
( if [ ! -z "$BOOTIMAGE" ]; then
5+
ui_print "- Target boot image: $BOOTIMAGE"
6+
mkdir "$TMPDIR/boot"
7+
dd if=$BOOTIMAGE of="$TMPDIR/boot/boot.img"
8+
ui_print "- Unpack boot image"
9+
cd "$TMPDIR/boot" || exit 1
10+
/data/adb/magisk/magiskboot unpack boot.img
11+
ui_print "- Add bootloop protector script"
12+
cat <<EOF > safemode.rc
13+
# safe mode trigger
14+
on post-fs
15+
exec u:r:magisk:s0 root root -- /system/bin/sh \${MAGISKTMP}/safemode.sh
16+
17+
EOF
18+
cat <<EOF >safemode.sh
19+
for dir in /cache /data/unencrypted /metadata /persist /mnt/vendor/persist; do
20+
if [ -f "\$dir/disable_magisk" ]; then
21+
DISABLE=true
22+
rm -rf "\$dir/disable_magisk"
23+
fi
24+
done
25+
26+
[ "\$DISABLE" == "true" ] && setprop persist.sys.safemode 1
27+
EOF
28+
/data/adb/magisk/magiskboot cpio ramdisk.cpio \
29+
"mkdir 0750 overlay.d" \
30+
"mkdir 0750 overlay.d/sbin" \
31+
"rm overlay.d/safemode.rc" \
32+
"rm overlay.d/sbin/safemode.sh" \
33+
"add 0750 overlay.d/safemode.rc safemode.rc" \
34+
"add 0750 overlay.d/sbin/safemode.sh safemode.sh"
35+
ui_print "- Repack boot image"
36+
/data/adb/magisk/magiskboot repack boot.img
37+
ui_print "- Flashing new boot image"
38+
dd of=$BOOTIMAGE if="$TMPDIR/boot/new-boot.img"
39+
else
40+
ui_print "! Cannot detect target boot image"
41+
fi )
42+
43+
44+
445
ui_print "- Module log is /cache/bootloop_saver.log"

module.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"versionCode": 10007,
3-
"version": "v1.5",
4-
"zipUrl": "https://github.com/Magisk-Modules-Alt-Repo/HuskyDG_BootloopSaver/releases/download/v1.5/bootloop_protector.zip",
5-
"changelog": "https://raw.githubusercontent.com/Magisk-Modules-Alt-Repo/HuskyDG_BootloopSaver/v1.5/changelog.md"
2+
"versionCode": 10008,
3+
"version": "v1.6",
4+
"zipUrl": "https://github.com/Magisk-Modules-Alt-Repo/HuskyDG_BootloopSaver/releases/download/v1.6/bootloop_protector.zip",
5+
"changelog": "https://raw.githubusercontent.com/Magisk-Modules-Alt-Repo/HuskyDG_BootloopSaver/v1.6/changelog.md"
66
}

module.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id=huskydg_bootloopsaver
22
name=Magisk Bootloop Protector
3-
version=v1.5
4-
versionCode=10007
3+
version=v1.6
4+
versionCode=10008
55
author=HuskyDG
66
description=Protect your system from bootloop caused by Magisk modules by turning off all your modules and restart your system if bootloop is detected.
77
updateJson=https://raw.githubusercontent.com/Magisk-Modules-Alt-Repo/HuskyDG_BootloopSaver/master/module.json

uninstall.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
MAGISKTMP="$(magisk --path)"
2+
. /data/adb/magisk/util_functions.sh
3+
get_flags
4+
find_boot_image
5+
( if [ ! -z "$BOOTIMAGE" ]; then
6+
mkdir -p "$TMPDIR/boot"
7+
dd if=$BOOTIMAGE of="$TMPDIR/boot/boot.img""
8+
cd "$TMPDIR/boot" || exit 1
9+
/data/adb/magisk/magiskboot unpack boot.img"
10+
/data/adb/magisk/magiskboot cpio ramdisk.cpio \
11+
"rm overlay.d/safemode.rc" \
12+
"rm overlay.d/sbin/safemode.sh"
13+
/data/adb/magisk/magiskboot repack boot.img
14+
dd of=$BOOTIMAGE if="$TMPDIR/boot/new-boot.img"
15+
fi )

0 commit comments

Comments
 (0)