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

61 lines
1.1 KiB
Bash

#MAGISK
############################################
# Magisk Flash Script (updater-script)
############################################
##############
# Preparation
##############
find_magisk_apk
# Default permissions
umask 022
OUTFD=$2
APK="$3"
COMMONDIR=$INSTALLER/assets
CHROMEDIR=$INSTALLER/assets/chromeos
setup_flashable
############
# Detection
############
if echo $MAGISK_VER | grep -q '\.'; then
PRETTY_VER=$MAGISK_VER
else
PRETTY_VER="$MAGISK_VER($MAGISK_VER_CODE)"
fi
print_title "Magisk $PRETTY_VER Installer"
is_mounted /data || mount /data || is_mounted /cache || mount /cache
mount_partitions
check_data
get_flags
find_boot_image
[ -z $BOOTIMAGE ] && abort "! Unable to detect target image"
ui_print "- Target image: $BOOTIMAGE"
# Detect version and architecture
api_level_arch_detect
[ $API -lt 21 ] && abort "! Magisk only support Android 5.0 and above"
ui_print "- Device platform: $ARCH"
##################
# Image Patching
##################
install_magisk
# Cleanups
$BOOTMODE || recovery_cleanup
rm -rf $TMPDIR
ui_print "- Done"
exit 0