2017-08-02 02:21:50 +08:00
|
|
|
#MAGISK
|
2020-03-08 22:25:06 -07:00
|
|
|
############################################
|
2019-11-02 00:26:08 -03:00
|
|
|
# Magisk Flash Script (updater-script)
|
2020-03-08 22:25:06 -07:00
|
|
|
############################################
|
2016-09-14 10:31:13 +08:00
|
|
|
|
2020-03-20 07:44:08 -03:00
|
|
|
##############
|
2017-07-10 00:17:34 +08:00
|
|
|
# Preparation
|
2020-03-20 07:44:08 -03:00
|
|
|
##############
|
2017-07-10 00:17:34 +08:00
|
|
|
|
2016-11-13 16:58:43 +08:00
|
|
|
# Default permissions
|
|
|
|
umask 022
|
|
|
|
|
2016-09-14 10:31:13 +08:00
|
|
|
OUTFD=$2
|
2021-01-22 02:28:53 -08:00
|
|
|
APK="$3"
|
|
|
|
COMMONDIR=$INSTALLER/assets
|
|
|
|
CHROMEDIR=$INSTALLER/assets/chromeos
|
2016-09-14 10:31:13 +08:00
|
|
|
|
2017-09-16 03:48:58 +08:00
|
|
|
if [ ! -f $COMMONDIR/util_functions.sh ]; then
|
2017-06-24 23:38:20 +09:00
|
|
|
echo "! Unable to extract zip file!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-01-22 02:28:53 -08:00
|
|
|
# Load utility functions
|
2017-06-19 00:15:44 +08:00
|
|
|
. $COMMONDIR/util_functions.sh
|
|
|
|
|
2018-08-28 22:03:12 -04:00
|
|
|
setup_flashable
|
2017-07-10 00:17:34 +08:00
|
|
|
|
2020-03-20 07:44:08 -03:00
|
|
|
############
|
2017-07-10 00:17:34 +08:00
|
|
|
# Detection
|
2020-03-20 07:44:08 -03:00
|
|
|
############
|
2017-07-10 00:17:34 +08:00
|
|
|
|
2020-03-23 01:17:13 -07:00
|
|
|
if echo $MAGISK_VER | grep -q '\.'; then
|
|
|
|
PRETTY_VER=$MAGISK_VER
|
|
|
|
else
|
|
|
|
PRETTY_VER="$MAGISK_VER($MAGISK_VER_CODE)"
|
|
|
|
fi
|
2020-03-08 22:25:06 -07:00
|
|
|
print_title "Magisk $PRETTY_VER Installer"
|
2016-09-14 10:31:13 +08:00
|
|
|
|
2019-04-06 13:04:17 -04:00
|
|
|
is_mounted /data || mount /data || is_mounted /cache || mount /cache
|
2017-09-13 04:07:25 +08:00
|
|
|
mount_partitions
|
2018-10-20 17:10:35 -04:00
|
|
|
check_data
|
2018-06-18 01:40:56 +08:00
|
|
|
get_flags
|
2019-04-05 05:13:57 +08:00
|
|
|
find_boot_image
|
|
|
|
|
2018-07-04 23:46:16 +08:00
|
|
|
[ -z $BOOTIMAGE ] && abort "! Unable to detect target image"
|
|
|
|
ui_print "- Target image: $BOOTIMAGE"
|
2018-02-10 03:31:00 +08:00
|
|
|
|
2017-07-02 21:36:09 +08:00
|
|
|
# Detect version and architecture
|
|
|
|
api_level_arch_detect
|
2016-10-03 04:34:50 +08:00
|
|
|
|
2023-03-17 20:08:31 +08:00
|
|
|
[ $API -lt 23 ] && abort "! Magisk only support Android 6.0 and above"
|
2016-10-30 06:13:59 +08:00
|
|
|
|
2021-05-13 00:21:04 -07:00
|
|
|
ui_print "- Device platform: $ABI"
|
2016-10-30 06:13:59 +08:00
|
|
|
|
2021-05-13 00:21:04 -07:00
|
|
|
BINDIR=$INSTALLER/lib/$ABI
|
2021-01-22 02:28:53 -08:00
|
|
|
cd $BINDIR
|
|
|
|
for file in lib*.so; do mv "$file" "${file:3:${#file}-6}"; done
|
|
|
|
cd /
|
2021-05-13 00:21:04 -07:00
|
|
|
cp -af $INSTALLER/lib/$ABI32/libmagisk32.so $BINDIR/magisk32 2>/dev/null
|
2016-10-30 06:13:59 +08:00
|
|
|
|
2018-02-10 03:31:00 +08:00
|
|
|
# Check if system root is installed and remove
|
2020-12-09 19:58:38 +08:00
|
|
|
$BOOTMODE || remove_system_su
|
2018-02-10 03:31:00 +08:00
|
|
|
|
2020-03-20 07:44:08 -03:00
|
|
|
##############
|
2016-11-13 16:58:43 +08:00
|
|
|
# Environment
|
2020-03-20 07:44:08 -03:00
|
|
|
##############
|
2016-11-13 16:58:43 +08:00
|
|
|
|
2017-04-22 07:05:10 +08:00
|
|
|
ui_print "- Constructing environment"
|
2017-07-25 02:02:19 +08:00
|
|
|
|
2017-04-22 07:05:10 +08:00
|
|
|
# Copy required files
|
2017-11-06 05:41:03 +08:00
|
|
|
rm -rf $MAGISKBIN/* 2>/dev/null
|
|
|
|
mkdir -p $MAGISKBIN 2>/dev/null
|
2021-01-22 02:28:53 -08:00
|
|
|
cp -af $BINDIR/. $COMMONDIR/. $BBBIN $MAGISKBIN
|
2022-12-26 15:59:56 -08:00
|
|
|
|
|
|
|
# Remove files only used by the Magisk app
|
|
|
|
rm -f $MAGISKBIN/bootctl $MAGISKBIN/main.jar \
|
|
|
|
$MAGISKBIN/module_installer.sh $MAGISKBIN/uninstaller.sh
|
|
|
|
|
2017-04-22 07:05:10 +08:00
|
|
|
chmod -R 755 $MAGISKBIN
|
2017-02-04 18:44:07 +08:00
|
|
|
|
2017-06-19 00:15:44 +08:00
|
|
|
# addon.d
|
|
|
|
if [ -d /system/addon.d ]; then
|
|
|
|
ui_print "- Adding addon.d survival script"
|
2020-04-20 01:20:19 -03:00
|
|
|
blockdev --setrw /dev/block/mapper/system$SLOT 2>/dev/null
|
2021-01-22 02:28:53 -08:00
|
|
|
mount -o rw,remount /system || mount -o rw,remount /
|
2018-08-03 22:40:49 +08:00
|
|
|
ADDOND=/system/addon.d/99-magisk.sh
|
2020-02-09 03:07:49 -08:00
|
|
|
cp -af $COMMONDIR/addon.d.sh $ADDOND
|
2018-08-03 22:40:49 +08:00
|
|
|
chmod 755 $ADDOND
|
2017-06-19 00:15:44 +08:00
|
|
|
fi
|
|
|
|
|
2021-01-22 02:28:53 -08:00
|
|
|
##################
|
|
|
|
# Image Patching
|
|
|
|
##################
|
2017-03-12 18:13:58 +08:00
|
|
|
|
2020-01-01 14:02:44 +08:00
|
|
|
install_magisk
|
2016-09-14 10:31:13 +08:00
|
|
|
|
2017-09-05 21:44:22 +08:00
|
|
|
# Cleanups
|
|
|
|
$BOOTMODE || recovery_cleanup
|
2017-08-12 23:15:39 +08:00
|
|
|
rm -rf $TMPDIR
|
2017-07-31 03:03:52 +08:00
|
|
|
|
2016-09-14 10:31:13 +08:00
|
|
|
ui_print "- Done"
|
|
|
|
exit 0
|