mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-08-24 16:17:36 +00:00
Update scripts
This commit is contained in:
@@ -64,7 +64,8 @@ installation() {
|
||||
# Source the boot patcher
|
||||
. ./boot_patch.sh "$BOOTIMAGE"
|
||||
|
||||
flash_boot_image new-boot.img "$BOOTIMAGE"
|
||||
ui_print "- Flashing new boot image"
|
||||
flash_image new-boot.img "$BOOTIMAGE"
|
||||
rm -f new-boot.img
|
||||
|
||||
if [ -f stock_boot* ]; then
|
||||
|
@@ -114,7 +114,8 @@ cd $MAGISKBIN
|
||||
# Source the boot patcher
|
||||
. ./boot_patch.sh "$BOOTIMAGE"
|
||||
|
||||
flash_boot_image new-boot.img "$BOOTIMAGE"
|
||||
ui_print "- Flashing new boot image"
|
||||
flash_image new-boot.img "$BOOTIMAGE"
|
||||
rm -f new-boot.img
|
||||
|
||||
if [ -f stock_boot* ]; then
|
||||
|
@@ -95,17 +95,16 @@ case $? in
|
||||
;;
|
||||
1 ) # Magisk patched
|
||||
ui_print "- Magisk patched image detected"
|
||||
./magisk --unlock-blocks 2>/dev/null
|
||||
# Find SHA1 of stock boot image
|
||||
[ -z $SHA1 ] && SHA1=`./magiskboot --cpio ramdisk.cpio sha1 2>/dev/null`
|
||||
STOCKBOOT=/data/stock_boot_${SHA1}.img.gz
|
||||
STOCKDTBO=/data/stock_dtbo.img.gz
|
||||
if [ -f $STOCKBOOT ]; then
|
||||
ui_print "- Restoring stock boot image"
|
||||
gzip -d < $STOCKBOOT | cat - /dev/zero > $BOOTIMAGE 2>/dev/null
|
||||
if [ -f $DTBOIMAGE -a -f $STOCKDTBO ]; then
|
||||
flash_image $STOCKBOOT $BOOTIMAGE
|
||||
if [ -f $STOCKDTBO -a -b "$DTBOIMAGE" ]; then
|
||||
ui_print "- Restoring stock dtbo image"
|
||||
gzip -d < $STOCKDTBO > $DTBOIMAGE
|
||||
flash_image $STOCKDTBO $DTBOIMAGE
|
||||
fi
|
||||
else
|
||||
ui_print "! Boot image backup unavailable"
|
||||
@@ -114,7 +113,8 @@ case $? in
|
||||
./magiskboot --repack $BOOTIMAGE
|
||||
# Sign chromeos boot
|
||||
$CHROMEOS && sign_chromeos
|
||||
flash_boot_image new-boot.img $BOOTIMAGE
|
||||
ui_print "- Flashing restored boot image"
|
||||
flash_image new-boot.img $BOOTIMAGE
|
||||
fi
|
||||
;;
|
||||
2 ) # Other patched
|
||||
|
@@ -189,29 +189,25 @@ find_boot_image() {
|
||||
fi
|
||||
}
|
||||
|
||||
flash_boot_image() {
|
||||
flash_image() {
|
||||
# Make sure all blocks are writable
|
||||
$MAGISKBIN/magisk --unlock-blocks 2>/dev/null
|
||||
case "$1" in
|
||||
*.gz) COMMAND="gzip -d < '$1'";;
|
||||
*) COMMAND="cat '$1'";;
|
||||
*.gz) COM1="$MAGISKBIN/magiskboot --decompress '$1' - 2>/dev/null";;
|
||||
*) COM1="cat '$1'";;
|
||||
esac
|
||||
if $BOOTSIGNED; then
|
||||
SIGNCOM="$BOOTSIGNER -sign"
|
||||
ui_print "- Sign boot image with test keys"
|
||||
COM2="$BOOTSIGNER -sign"
|
||||
ui_print "- Sign image with test keys"
|
||||
else
|
||||
SIGNCOM="cat -"
|
||||
COM2="cat -"
|
||||
fi
|
||||
if [ -b "$2" ]; then
|
||||
eval $COM1 | eval $COM2 | cat - /dev/zero > "$2" 2>/dev/null
|
||||
else
|
||||
ui_print "- Not block device, storing image"
|
||||
eval $COM1 | eval $COM2 > "$2" 2>/dev/null
|
||||
fi
|
||||
case "$2" in
|
||||
/dev/block/*)
|
||||
ui_print "- Flashing new boot image"
|
||||
eval $COMMAND | eval $SIGNCOM | cat - /dev/zero 2>/dev/null | dd of="$2" bs=4096 2>/dev/null
|
||||
;;
|
||||
*)
|
||||
ui_print "- Storing new boot image"
|
||||
eval $COMMAND | eval $SIGNCOM | dd of="$2" bs=4096 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
find_dtbo_image() {
|
||||
|
Reference in New Issue
Block a user