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