2018-02-27 14:42:14 +00:00
|
|
|
#!/sbin/sh
|
|
|
|
|
|
|
|
TMPDIR=/dev/tmp
|
2019-04-23 09:46:32 +00:00
|
|
|
MOUNTPATH=/dev/magisk_img
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
# Default permissions
|
|
|
|
umask 022
|
|
|
|
|
|
|
|
# Initial cleanup
|
|
|
|
rm -rf $TMPDIR 2>/dev/null
|
2019-04-23 09:46:32 +00:00
|
|
|
mkdir -p $TMPDIR
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
# echo before loading util_functions
|
|
|
|
ui_print() { echo "$1"; }
|
|
|
|
|
|
|
|
require_new_magisk() {
|
2019-04-23 09:46:32 +00:00
|
|
|
ui_print "***********************************"
|
|
|
|
ui_print " Please install the latest Magisk! "
|
|
|
|
ui_print "***********************************"
|
2018-02-27 14:42:14 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-04-23 09:46:32 +00:00
|
|
|
imageless_magisk() {
|
|
|
|
[ $MAGISK_VER_CODE -gt 18100 ]
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2018-02-27 14:42:14 +00:00
|
|
|
##########################################################################################
|
|
|
|
# Environment
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
OUTFD=$2
|
2019-04-23 09:46:32 +00:00
|
|
|
ZIPFILE=$3
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
mount /data 2>/dev/null
|
|
|
|
|
2018-09-13 05:02:36 +00:00
|
|
|
# Load utility functions
|
|
|
|
if [ -f /data/adb/magisk/util_functions.sh ]; then
|
|
|
|
. /data/adb/magisk/util_functions.sh
|
2019-04-23 09:46:32 +00:00
|
|
|
NVBASE=/data/adb
|
2018-09-13 05:02:36 +00:00
|
|
|
else
|
|
|
|
require_new_magisk
|
|
|
|
fi
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
# Preperation for flashable zips
|
2018-09-13 05:02:36 +00:00
|
|
|
setup_flashable
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
# Mount partitions
|
|
|
|
mount_partitions
|
|
|
|
|
|
|
|
# Detect version and architecture
|
|
|
|
api_level_arch_detect
|
|
|
|
|
|
|
|
# Setup busybox and binaries
|
|
|
|
$BOOTMODE && boot_actions || recovery_actions
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Preparation
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
# Extract common files
|
2019-04-23 09:46:32 +00:00
|
|
|
unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2
|
2018-02-27 14:42:14 +00:00
|
|
|
|
2019-04-23 09:46:32 +00:00
|
|
|
[ ! -f $TMPDIR/install.sh ] && abort "! Unable to extract zip file!"
|
|
|
|
# Load install script
|
|
|
|
. $TMPDIR/install.sh
|
2018-02-27 14:42:14 +00:00
|
|
|
|
2019-04-23 09:46:32 +00:00
|
|
|
if imageless_magisk; then
|
|
|
|
$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
|
|
|
|
MODULEROOT=$NVBASE/$MODDIRNAME
|
|
|
|
else
|
|
|
|
$BOOTMODE && IMGNAME=magisk_merge.img || IMGNAME=magisk.img
|
|
|
|
IMG=$NVBASE/$IMGNAME
|
|
|
|
request_zip_size_check "$ZIPFILE"
|
|
|
|
mount_magisk_img
|
|
|
|
MODULEROOT=$MOUNTPATH
|
|
|
|
fi
|
|
|
|
|
|
|
|
MODID=`grep_prop id $TMPDIR/module.prop`
|
|
|
|
MODPATH=$MODULEROOT/$MODID
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
print_modname
|
|
|
|
|
|
|
|
ui_print "******************************"
|
|
|
|
ui_print "Powered by Magisk (@topjohnwu)"
|
|
|
|
ui_print "******************************"
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Install
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
# Create mod paths
|
|
|
|
rm -rf $MODPATH 2>/dev/null
|
|
|
|
mkdir -p $MODPATH
|
|
|
|
|
2019-04-23 09:46:32 +00:00
|
|
|
on_install
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
# Remove placeholder
|
|
|
|
rm -f $MODPATH/system/placeholder 2>/dev/null
|
|
|
|
|
2019-04-23 09:46:32 +00:00
|
|
|
# Custom uninstaller
|
|
|
|
[ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
# Auto Mount
|
2019-04-23 09:46:32 +00:00
|
|
|
if imageless_magisk; then
|
|
|
|
$SKIPMOUNT && touch $MODPATH/skip_mount
|
|
|
|
else
|
|
|
|
$SKIPMOUNT || touch $MODPATH/auto_mount
|
|
|
|
fi
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
# prop files
|
2019-04-23 09:46:32 +00:00
|
|
|
$PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
# Module info
|
2019-04-23 09:46:32 +00:00
|
|
|
cp -af $TMPDIR/module.prop $MODPATH/module.prop
|
2018-02-27 14:42:14 +00:00
|
|
|
if $BOOTMODE; then
|
|
|
|
# Update info for Magisk Manager
|
2019-04-23 09:46:32 +00:00
|
|
|
if imageless_magisk; then
|
|
|
|
mktouch $NVBASE/modules/$MODID/update
|
|
|
|
cp -af $TMPDIR/module.prop $NVBASE/modules/$MODID/module.prop
|
|
|
|
else
|
|
|
|
mktouch /sbin/.magisk/img/$MODID/update
|
|
|
|
cp -af $TMPDIR/module.prop /sbin/.magisk/img/$MODID/module.prop
|
|
|
|
fi
|
2018-02-27 14:42:14 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# post-fs-data mode scripts
|
2019-04-23 09:46:32 +00:00
|
|
|
$POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
# service mode scripts
|
2019-04-23 09:46:32 +00:00
|
|
|
$LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh
|
|
|
|
|
|
|
|
# Handle replace folders
|
|
|
|
for TARGET in $REPLACE; do
|
|
|
|
mktouch $MODPATH$TARGET/.replace
|
|
|
|
done
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
ui_print "- Setting permissions"
|
|
|
|
set_permissions
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Finalizing
|
|
|
|
##########################################################################################
|
|
|
|
|
2019-04-23 09:46:32 +00:00
|
|
|
cd /
|
|
|
|
imageless_magisk || unmount_magisk_img
|
2018-02-27 14:42:14 +00:00
|
|
|
$BOOTMODE || recovery_cleanup
|
2019-04-23 09:46:32 +00:00
|
|
|
rm -rf $TMPDIR $MOUNTPATH
|
2018-02-27 14:42:14 +00:00
|
|
|
|
|
|
|
ui_print "- Done"
|
2019-04-23 09:46:32 +00:00
|
|
|
exit 0
|