mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 13:35:27 +00:00
Update scripts
This commit is contained in:
parent
ffa005e4ab
commit
9cb1cf756f
@ -13,9 +13,11 @@
|
|||||||
main() {
|
main() {
|
||||||
# Magisk binaries
|
# Magisk binaries
|
||||||
MAGISKBIN=/data/magisk
|
MAGISKBIN=/data/magisk
|
||||||
# This script always run in recovery
|
# This script always runs in recovery
|
||||||
BOOTMODE=false
|
BOOTMODE=false
|
||||||
|
|
||||||
|
mount /data 2>/dev/null
|
||||||
|
|
||||||
if [ ! -d $MAGISKBIN ]; then
|
if [ ! -d $MAGISKBIN ]; then
|
||||||
echo "! Cannot find Magisk binaries!"
|
echo "! Cannot find Magisk binaries!"
|
||||||
exit 1
|
exit 1
|
||||||
@ -24,26 +26,21 @@ main() {
|
|||||||
# Wait for post addon.d processes to finish
|
# Wait for post addon.d processes to finish
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
mount -o ro /system 2>/dev/null
|
|
||||||
mount -o ro /vendor 2>/dev/null
|
|
||||||
mount /data 2>/dev/null
|
|
||||||
|
|
||||||
# Load utility functions
|
# Load utility functions
|
||||||
. $MAGISKBIN/util_functions.sh
|
. $MAGISKBIN/util_functions.sh
|
||||||
|
|
||||||
[ -f /system/build.prop ] || abort "! /system could not be mounted!"
|
|
||||||
|
|
||||||
ui_print "************************"
|
ui_print "************************"
|
||||||
ui_print "* Magisk v$MAGISK_VER addon.d"
|
ui_print "* Magisk v$MAGISK_VER addon.d"
|
||||||
ui_print "************************"
|
ui_print "************************"
|
||||||
|
|
||||||
|
mount_partitions
|
||||||
|
|
||||||
api_level_arch_detect
|
api_level_arch_detect
|
||||||
|
|
||||||
# Check if system root is installed and remove
|
|
||||||
remove_system_su
|
|
||||||
|
|
||||||
recovery_actions
|
recovery_actions
|
||||||
|
|
||||||
|
remove_system_su
|
||||||
|
|
||||||
find_boot_image
|
find_boot_image
|
||||||
[ -z $BOOTIMAGE ] && abort "! Unable to detect boot image"
|
[ -z $BOOTIMAGE ] && abort "! Unable to detect boot image"
|
||||||
ui_print "- Found Boot Image: $BOOTIMAGE"
|
ui_print "- Found Boot Image: $BOOTIMAGE"
|
||||||
@ -54,18 +51,15 @@ main() {
|
|||||||
# Source the boot patcher
|
# Source the boot patcher
|
||||||
. $MAGISKBIN/boot_patch.sh "$BOOTIMAGE"
|
. $MAGISKBIN/boot_patch.sh "$BOOTIMAGE"
|
||||||
|
|
||||||
[ -f stock_boot* ] && rm -f /data/stock_boot* 2>/dev/null
|
if [ -f stock_boot* ]; then
|
||||||
|
rm -f /data/stock_boot* 2>/dev/null
|
||||||
ui_print "- Flashing new boot image"
|
mv stock_boot* /data
|
||||||
if [ -L "$BOOTIMAGE" ]; then
|
|
||||||
dd if=new-boot.img of="$BOOTIMAGE" bs=4096
|
|
||||||
else
|
|
||||||
cat new-boot.img /dev/zero | dd of="$BOOTIMAGE" bs=4096 >/dev/null 2>&1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
flash_boot_image new-boot.img $BOOTIMAGE
|
||||||
rm -f new-boot.img
|
rm -f new-boot.img
|
||||||
|
|
||||||
cd /
|
cd /
|
||||||
|
|
||||||
recovery_cleanup
|
recovery_cleanup
|
||||||
|
|
||||||
ui_print "- Done"
|
ui_print "- Done"
|
||||||
|
@ -180,7 +180,7 @@ if [ ! -z $SHA1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if $SKIP_INITRAMFS; then
|
if $SKIP_INITRAMFS; then
|
||||||
cpio_add 750 init ./magiskinit
|
cpio_add 750 init magiskinit
|
||||||
cpio_mkdir 000 overlay
|
cpio_mkdir 000 overlay
|
||||||
cpio_add 750 overlay/init.magisk.rc init.magisk.rc
|
cpio_add 750 overlay/init.magisk.rc init.magisk.rc
|
||||||
cpio_mkdir 750 overlay/sbin
|
cpio_mkdir 750 overlay/sbin
|
||||||
@ -220,7 +220,7 @@ rm -f ramdisk.cpio.orig
|
|||||||
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
|
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
|
||||||
|
|
||||||
# skip_initramfs -> want_initramfs
|
# skip_initramfs -> want_initramfs
|
||||||
./magiskboot --hexpatch kernel \
|
$SKIP_INITRAMFS && ./magiskboot --hexpatch kernel \
|
||||||
736B69705F696E697472616D6673 \
|
736B69705F696E697472616D6673 \
|
||||||
77616E745F696E697472616D6673
|
77616E745F696E697472616D6673
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ ui_print "************************"
|
|||||||
ui_print "* Magisk v$MAGISK_VER Installer"
|
ui_print "* Magisk v$MAGISK_VER Installer"
|
||||||
ui_print "************************"
|
ui_print "************************"
|
||||||
|
|
||||||
is_mounted /data || mount /data
|
is_mounted /data || mount /data || is_mounted /cache || mount /cache || abort "! Unable to mount partitions"
|
||||||
mount_partitions
|
mount_partitions
|
||||||
|
|
||||||
# read override variables
|
# read override variables
|
||||||
@ -85,7 +85,7 @@ if $BOOTMODE; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Save our stock boot image dump before removing it
|
# Save our stock boot image dump before removing it
|
||||||
[ -f $MAGISKBIN/stock_boot* ] && mv $MAGISKBIN/stock_boot* /data
|
mv /data/magisk/stock_boot* /data 2>/dev/null
|
||||||
|
|
||||||
# Copy required files
|
# Copy required files
|
||||||
rm -rf $MAGISKBIN 2>/dev/null
|
rm -rf $MAGISKBIN 2>/dev/null
|
||||||
@ -122,16 +122,10 @@ if [ -f stock_boot* ]; then
|
|||||||
mv stock_boot* /data
|
mv stock_boot* /data
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ui_print "- Flashing new boot image"
|
flash_boot_image new-boot.img "$BOOTIMAGE"
|
||||||
if [ -L "$BOOTIMAGE" ]; then
|
|
||||||
dd if=new-boot.img of="$BOOTIMAGE" bs=4096
|
|
||||||
else
|
|
||||||
cat new-boot.img /dev/zero | dd of="$BOOTIMAGE" bs=4096 >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
rm -f new-boot.img
|
rm -f new-boot.img
|
||||||
|
|
||||||
cd /
|
cd /
|
||||||
|
|
||||||
# Cleanups
|
# Cleanups
|
||||||
$BOOTMODE || recovery_cleanup
|
$BOOTMODE || recovery_cleanup
|
||||||
rm -rf $TMPDIR
|
rm -rf $TMPDIR
|
||||||
|
@ -86,12 +86,20 @@ getvar() {
|
|||||||
eval $VARNAME=\$VALUE
|
eval $VARNAME=\$VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolve_link() {
|
||||||
|
RESOLVED="$1"
|
||||||
|
while RESOLVE=`readlink $RESOLVED`; do
|
||||||
|
RESOLVED=$RESOLVE
|
||||||
|
done
|
||||||
|
echo $RESOLVED
|
||||||
|
}
|
||||||
|
|
||||||
find_boot_image() {
|
find_boot_image() {
|
||||||
if [ -z "$BOOTIMAGE" ]; then
|
if [ -z "$BOOTIMAGE" ]; then
|
||||||
if [ ! -z $SLOT ]; then
|
if [ ! -z $SLOT ]; then
|
||||||
BOOTIMAGE=`find /dev/block -iname boot$SLOT | head -n 1` 2>/dev/null
|
BOOTIMAGE=`find /dev/block -iname boot$SLOT | head -n 1` 2>/dev/null
|
||||||
else
|
else
|
||||||
for BLOCK in boot_a kern-a android_boot kernel boot lnx; do
|
for BLOCK in boot_a kern-a android_boot kernel boot lnx bootimg; do
|
||||||
BOOTIMAGE=`find /dev/block -iname $BLOCK | head -n 1` 2>/dev/null
|
BOOTIMAGE=`find /dev/block -iname $BLOCK | head -n 1` 2>/dev/null
|
||||||
[ ! -z $BOOTIMAGE ] && break
|
[ ! -z $BOOTIMAGE ] && break
|
||||||
done
|
done
|
||||||
@ -100,11 +108,11 @@ find_boot_image() {
|
|||||||
# Recovery fallback
|
# Recovery fallback
|
||||||
if [ -z "$BOOTIMAGE" ]; then
|
if [ -z "$BOOTIMAGE" ]; then
|
||||||
for FSTAB in /etc/*fstab*; do
|
for FSTAB in /etc/*fstab*; do
|
||||||
BOOTIMAGE=`grep -v '#' $FSTAB | grep -E '\b/boot\b' | grep -oE '/dev/[a-zA-Z0-9_./-]*'`
|
BOOTIMAGE=`grep -v '#' $FSTAB | grep -E '/boot[^a-zA-Z]' | grep -oE '/dev/[a-zA-Z0-9_./-]*'`
|
||||||
[ ! -z $BOOTIMAGE ] && break
|
[ ! -z $BOOTIMAGE ] && break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
[ -L "$BOOTIMAGE" ] && BOOTIMAGE=`readlink $BOOTIMAGE`
|
BOOTIMAGE=`resolve_link $BOOTIMAGE`
|
||||||
}
|
}
|
||||||
|
|
||||||
migrate_boot_backup() {
|
migrate_boot_backup() {
|
||||||
@ -121,7 +129,24 @@ migrate_boot_backup() {
|
|||||||
mv /data/stock_boot.img $STOCKDUMP
|
mv /data/stock_boot.img $STOCKDUMP
|
||||||
./magiskboot --compress $STOCKDUMP
|
./magiskboot --compress $STOCKDUMP
|
||||||
fi
|
fi
|
||||||
[ -f /data/magisk/stock_boot* ] && mv /data/magisk/stock_boot* /data
|
mv /data/magisk/stock_boot* /data 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
flash_boot_image() {
|
||||||
|
case "$1" in
|
||||||
|
*.gz) COMMAND="gzip -d < \"$1\"";;
|
||||||
|
*) COMMAND="cat \"$1\"";;
|
||||||
|
esac
|
||||||
|
case "$2" in
|
||||||
|
/dev/block/*)
|
||||||
|
ui_print "- Flashing new boot image"
|
||||||
|
eval $COMMAND | cat - /dev/zero | dd of="$2" bs=4096 >/dev/null 2>&1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ui_print "- Storing new boot image"
|
||||||
|
eval $COMMAND | dd of="$2" bs=4096 >/dev/null 2>&1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
sign_chromeos() {
|
sign_chromeos() {
|
||||||
|
Loading…
Reference in New Issue
Block a user