magisk-ghid/utils.sh
2021-04-18 14:27:01 -07:00

64 lines
1.6 KiB
Bash

# get_flags() {
# # override variables
# getvar KEEPVERITY
# getvar KEEPFORCEENCRYPT
# getvar RECOVERYMODE
# if [ -z $KEEPVERITY ]; then
# if $SYSTEM_ROOT; then
# KEEPVERITY=true
# ui_print "- System-as-root, keep dm/avb-verity"
# else
# KEEPVERITY=false
# fi
# fi
# ISENCRYPTED=false
# grep ' /data ' /proc/mounts | grep -q 'dm-' && ISENCRYPTED=true
# [ "$(getprop ro.crypto.state)" = "encrypted" ] && ISENCRYPTED=true
# if [ -z $KEEPFORCEENCRYPT ]; then
# # No data access means unable to decrypt in recovery
# if $ISENCRYPTED || ! $DATA; then
# KEEPFORCEENCRYPT=true
# ui_print "- Encrypted data, keep forceencrypt"
# else
# KEEPFORCEENCRYPT=false
# fi
# fi
# [ -z $RECOVERYMODE ] && RECOVERYMODE=false
# }
install_magisk() {
cd $TMPDIR
mkdir boot_patching
cd boot_patching/
# Dump image for MTD/NAND character device boot partitions
if [ -c $BOOTIMAGE ]; then
nanddump -f boot.img $BOOTIMAGE
local BOOTNAND=$BOOTIMAGE
BOOTIMAGE=boot.img
fi
if [ $API -ge 21 ]; then
eval $BOOTSIGNER -verify < $BOOTIMAGE && BOOTSIGNED=true
$BOOTSIGNED && ui_print "- Boot image is signed with AVB 1.0"
fi
# Source the boot patcher
. "$MODPATH/boot_patch.sh"
if [ -f new-boot.img ]; then
ui_print "- Flashing new boot image"
# Restore the original boot partition path
[ "$BOOTNAND" ] && BOOTIMAGE=$BOOTNAND
flash_image new-boot.img "$BOOTIMAGE" || abort "! Insufficient partition size"
rm -f new-boot.img
run_migrations
fi
$MAGISKBIN/magiskboot cleanup
}