mirror of
https://github.com/topjohnwu/Magisk
synced 2024-11-11 17:38:25 +01:00
Update flash script
This commit is contained in:
parent
57bdd9d3bf
commit
aa309087fd
@ -62,7 +62,7 @@ ui_print() {
|
|||||||
getvar() {
|
getvar() {
|
||||||
local VARNAME=$1
|
local VARNAME=$1
|
||||||
local VALUE=$(eval echo \$"$VARNAME");
|
local VALUE=$(eval echo \$"$VARNAME");
|
||||||
for FILE in /data/.magisk /cache/.magisk /system/.magisk; do
|
for FILE in /dev/.magisk /data/.magisk /cache/.magisk /system/.magisk; do
|
||||||
if [ -z "$VALUE" ]; then
|
if [ -z "$VALUE" ]; then
|
||||||
LINE=$(cat $FILE 2>/dev/null | grep "$VARNAME=")
|
LINE=$(cat $FILE 2>/dev/null | grep "$VARNAME=")
|
||||||
if [ ! -z "$LINE" ]; then
|
if [ ! -z "$LINE" ]; then
|
||||||
@ -203,42 +203,12 @@ if [ ! -f '/system/build.prop' ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
API=$(grep_prop ro.build.version.sdk)
|
|
||||||
ABI=$(grep_prop ro.product.cpu.abi | cut -c-3)
|
|
||||||
ABI2=$(grep_prop ro.product.cpu.abi2 | cut -c-3)
|
|
||||||
ABILONG=$(grep_prop ro.product.cpu.abi)
|
|
||||||
|
|
||||||
ARCH=arm
|
|
||||||
IS64BIT=false
|
|
||||||
if [ "$ABI" = "x86" ]; then ARCH=x86; fi;
|
|
||||||
if [ "$ABI2" = "x86" ]; then ARCH=x86; fi;
|
|
||||||
if [ "$ABILONG" = "arm64-v8a" ]; then ARCH=arm64; IS64BIT=true; fi;
|
|
||||||
if [ "$ABILONG" = "x86_64" ]; then ARCH=x64; IS64BIT=true; fi;
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$API" -lt "21" ]; then
|
|
||||||
ui_print "! Magisk is only for Lollipop 5.0+ (SDK 21+)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ui_print "- Device platform: $ARCH"
|
|
||||||
|
|
||||||
BINDIR=$INSTALLER/arm
|
|
||||||
if [ "$ARCH" = "x86" -o "$ARCH" = "x64" ]; then
|
|
||||||
BINDIR=$INSTALLER/x86
|
|
||||||
fi
|
|
||||||
|
|
||||||
find_boot_image
|
|
||||||
if [ -z "$BOOTIMAGE" ]; then
|
|
||||||
ui_print "! Unable to detect boot image"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$NOOVERRIDE" ]; then
|
if [ -z "$NOOVERRIDE" ]; then
|
||||||
# read override variables
|
# read override variables
|
||||||
getvar KEEPVERITY
|
getvar KEEPVERITY
|
||||||
getvar KEEPFORCEENCRYPT
|
getvar KEEPFORCEENCRYPT
|
||||||
getvar NORESTORE
|
getvar NORESTORE
|
||||||
|
getvar BOOTIMAGE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$KEEPVERITY" ]; then
|
if [ -z "$KEEPVERITY" ]; then
|
||||||
@ -260,27 +230,32 @@ if [ $? -eq 0 ]; then
|
|||||||
SAMSUNG=true
|
SAMSUNG=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################################################################################
|
API=$(grep_prop ro.build.version.sdk)
|
||||||
# Environment
|
ABI=$(grep_prop ro.product.cpu.abi | cut -c-3)
|
||||||
##########################################################################################
|
ABI2=$(grep_prop ro.product.cpu.abi2 | cut -c-3)
|
||||||
|
ABILONG=$(grep_prop ro.product.cpu.abi)
|
||||||
|
|
||||||
ui_print "- Constructing environment"
|
ARCH=arm
|
||||||
|
IS64BIT=false
|
||||||
|
if [ "$ABI" = "x86" ]; then ARCH=x86; fi;
|
||||||
|
if [ "$ABI2" = "x86" ]; then ARCH=x86; fi;
|
||||||
|
if [ "$ABILONG" = "arm64-v8a" ]; then ARCH=arm64; IS64BIT=true; fi;
|
||||||
|
if [ "$ABILONG" = "x86_64" ]; then ARCH=x64; IS64BIT=true; fi;
|
||||||
|
|
||||||
if (is_mounted /data); then
|
|
||||||
rm -rf /data/busybox /data/magisk 2>/dev/null
|
if [ "$API" -lt "21" ]; then
|
||||||
mkdir -p /data/busybox
|
ui_print "! Magisk is only for Lollipop 5.0+ (SDK 21+)"
|
||||||
cp -af $BINDIR /data/magisk
|
exit 1
|
||||||
cp -af $INSTALLER/common/init.magisk.rc $INSTALLER/common/magic_mask.sh /data/magisk
|
fi
|
||||||
chmod 755 /data/busybox /data/magisk /data/magisk/*
|
|
||||||
chcon 'u:object_r:system_file:s0' /data/busybox /data/magisk /data/magisk/*
|
ui_print "- Device platform: $ARCH"
|
||||||
/data/magisk/busybox --install -s /data/busybox
|
|
||||||
# Prevent issues
|
BINDIR=$INSTALLER/$ARCH
|
||||||
rm -f /data/busybox/su /data/busybox/sh
|
|
||||||
else
|
find_boot_image
|
||||||
rm -rf /cache/data_bin 2>/dev/null
|
if [ -z "$BOOTIMAGE" ]; then
|
||||||
mkdir -p /cache/data_bin
|
ui_print "! Unable to detect boot image"
|
||||||
cp -af $BINDIR /cache/data_bin
|
exit 1
|
||||||
cp -af $INSTALLER/common/init.magisk.rc $INSTALLER/common/magic_mask.sh /cache/data_bin
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@ -288,7 +263,7 @@ fi
|
|||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
# Fix SuperSU.....
|
# Fix SuperSU.....
|
||||||
($BOOTMODE) && /data/magisk/sepolicy-inject -s fsck --live
|
($BOOTMODE) && $BINDIR/sepolicy-inject -s fsck --live
|
||||||
|
|
||||||
if (is_mounted /data); then
|
if (is_mounted /data); then
|
||||||
IMG=/data/magisk.img
|
IMG=/data/magisk.img
|
||||||
@ -318,6 +293,29 @@ cp -af $INSTALLER/common/magiskhide/. /magisk/.core/magiskhide
|
|||||||
mkdir -p /magisk/zzsupersu
|
mkdir -p /magisk/zzsupersu
|
||||||
touch /magisk/zzsupersu/remove
|
touch /magisk/zzsupersu/remove
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Environment
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
ui_print "- Constructing environment"
|
||||||
|
|
||||||
|
if (is_mounted /data); then
|
||||||
|
rm -rf /data/busybox /data/magisk 2>/dev/null
|
||||||
|
mkdir -p /data/busybox
|
||||||
|
cp -af $BINDIR /data/magisk
|
||||||
|
cp -af $INSTALLER/common/init.magisk.rc $INSTALLER/common/magic_mask.sh /data/magisk
|
||||||
|
chmod 755 /data/busybox /data/magisk /data/magisk/*
|
||||||
|
/data/magisk/busybox --install -s /data/busybox
|
||||||
|
ln -s /data/magisk/busybox /data/busybox/busybox
|
||||||
|
# Prevent issues
|
||||||
|
rm -f /data/busybox/su /data/busybox/sh
|
||||||
|
else
|
||||||
|
rm -rf /cache/data_bin 2>/dev/null
|
||||||
|
mkdir -p /cache/data_bin
|
||||||
|
cp -af $BINDIR /cache/data_bin
|
||||||
|
cp -af $INSTALLER/common/init.magisk.rc $INSTALLER/common/magic_mask.sh /cache/data_bin
|
||||||
|
fi
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Boot image patch
|
# Boot image patch
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@ -374,17 +372,15 @@ if (! $NORESTORE); then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# SuperSU already backup stock boot, no need to do again
|
||||||
if (! $SUPERSU); then
|
if (! $SUPERSU); then
|
||||||
ui_print "- Creating backups"
|
ui_print "- Creating backups"
|
||||||
mkdir .backup 2>/dev/null
|
mkdir .backup 2>/dev/null
|
||||||
cp -af init.environ.rc *fstab* verity_key sepolicy .backup 2>/dev/null
|
cp -af init.environ.rc *fstab* verity_key sepolicy .backup 2>/dev/null
|
||||||
if (! $SUPERSU); then
|
if (is_mounted /data); then
|
||||||
# SuperSU already backup stock boot, no need to do again
|
cp -af $ORIGBOOT /data/stock_boot.img
|
||||||
if (is_mounted /data); then
|
else
|
||||||
cp -af $ORIGBOOT /data/stock_boot.img
|
cp -af $ORIGBOOT /cache/stock_boot.img
|
||||||
else
|
|
||||||
cp -af $ORIGBOOT /cache/stock_boot.img
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -400,7 +396,7 @@ for INIT in init*.rc; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Add magisk PATH
|
# Add magisk specific
|
||||||
if [ $(grep -c "export PATH" init.environ.rc) -eq "0" ]; then
|
if [ $(grep -c "export PATH" init.environ.rc) -eq "0" ]; then
|
||||||
sed -i "/on init/a\ \ \ \ export PATH /magisk/.core/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/magisk/.core/busybox" init.environ.rc
|
sed -i "/on init/a\ \ \ \ export PATH /magisk/.core/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/magisk/.core/busybox" init.environ.rc
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user