Created
August 6, 2020 04:19
-
-
Save tytydraco/d6212d330792d15c1176b2dd4912a8fb to your computer and use it in GitHub Desktop.
An Android Linux Kernel command line patch tool using Magisk's magiskboot binary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/system/bin/sh | |
# Written by Draco (tytydraco @ GitHub) | |
set -e | |
MAGISKBOOT="/data/adb/magisk/magiskboot" | |
err() { | |
echo -e "\e[91m[!] $@\e[39m" | |
exit 1 | |
} | |
[[ ! -f "$MAGISKBOOT" ]] && err "Failed to find magiskboot binary. Exiting." | |
mkdir -p /data/local/tmp/cmdpatch | |
cd /data/local/tmp/cmdpatch | |
SLOT=`getprop ro.boot.slot_suffix` | |
BOOT="boot$SLOT" | |
BOOTIMG="/dev/block/by-name/$BOOT" | |
dd if=$BOOTIMG of=/sdcard/$BOOT.img.bk | |
$MAGISKBOOT unpack -h $BOOTIMG | |
for tweak in "$@" | |
do | |
echo "=== $tweak ===" | |
local cmdline=`cat header | grep cmdline=` | |
[[ "$tweak" != *"$cmdline"* ]] && | |
sed -i "s/cmdline=/cmdline=$tweak /" header | |
done | |
$MAGISKBOOT repack $BOOTIMG new.img | |
dd if=new.img of=$BOOTIMG | |
rm -rf /data/local/tmp/cmdpatch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment