Update scripts
This commit is contained in:
parent
930c82316a
commit
e5c3183025
2
app
2
app
@ -1 +1 @@
|
|||||||
Subproject commit 1adf331268476405f22725518335ef49f6999fd9
|
Subproject commit 836d9afe1756070971731198d39e69c78cf3b527
|
@ -129,11 +129,6 @@ void daemon_init() {
|
|||||||
unlink("/data/magisk_debug.log");
|
unlink("/data/magisk_debug.log");
|
||||||
chmod("/data/adb", 0700);
|
chmod("/data/adb", 0700);
|
||||||
|
|
||||||
// Use shell glob to match files
|
|
||||||
exec_command_sync("sh", "-c",
|
|
||||||
"mv -f /data/adb/magisk/stock_*.img.gz /data;"
|
|
||||||
"rm -f /data/user*/*/magisk.db;", NULL);
|
|
||||||
|
|
||||||
LOGI("* Creating /sbin overlay");
|
LOGI("* Creating /sbin overlay");
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
main() {
|
main() {
|
||||||
# Magisk binaries
|
# Magisk binaries
|
||||||
MAGISKBIN=/data/adb/magisk
|
MAGISKBIN=/data/adb/magisk
|
||||||
# This script always runs in recovery
|
|
||||||
BOOTMODE=false
|
|
||||||
|
|
||||||
mount /data 2>/dev/null
|
mount /data 2>/dev/null
|
||||||
|
|
||||||
@ -41,7 +39,6 @@ main() {
|
|||||||
|
|
||||||
remove_system_su
|
remove_system_su
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
@ -59,13 +56,6 @@ main() {
|
|||||||
mv stock_boot* /data
|
mv stock_boot* /data
|
||||||
fi
|
fi
|
||||||
|
|
||||||
patch_dtbo_image
|
|
||||||
|
|
||||||
if [ -f stock_dtbo* ]; then
|
|
||||||
rm -f /data/stock_dtbo* 2>/dev/null
|
|
||||||
mv stock_dtbo* /data
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd /
|
cd /
|
||||||
recovery_cleanup
|
recovery_cleanup
|
||||||
|
|
||||||
|
@ -83,8 +83,6 @@ chmod -R 755 .
|
|||||||
# Unpack
|
# Unpack
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
migrate_boot_backup
|
|
||||||
|
|
||||||
CHROMEOS=false
|
CHROMEOS=false
|
||||||
|
|
||||||
ui_print "- Unpacking boot image"
|
ui_print "- Unpacking boot image"
|
||||||
|
@ -13,10 +13,6 @@
|
|||||||
# Preparation
|
# Preparation
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
# Detect whether in boot mode
|
|
||||||
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true || BOOTMODE=false
|
|
||||||
$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true
|
|
||||||
|
|
||||||
# This path should work in any cases
|
# This path should work in any cases
|
||||||
TMPDIR=/dev/tmp
|
TMPDIR=/dev/tmp
|
||||||
|
|
||||||
@ -24,7 +20,6 @@ INSTALLER=$TMPDIR/install
|
|||||||
COMMONDIR=$INSTALLER/common
|
COMMONDIR=$INSTALLER/common
|
||||||
APK=$COMMONDIR/magisk.apk
|
APK=$COMMONDIR/magisk.apk
|
||||||
CHROMEDIR=$INSTALLER/chromeos
|
CHROMEDIR=$INSTALLER/chromeos
|
||||||
COREDIR=/magisk/.core
|
|
||||||
|
|
||||||
# Default permissions
|
# Default permissions
|
||||||
umask 022
|
umask 022
|
||||||
@ -83,8 +78,8 @@ if is_mounted /data; then
|
|||||||
chmod 700 /data/adb 2>/dev/null
|
chmod 700 /data/adb 2>/dev/null
|
||||||
|
|
||||||
# Some legacy migration
|
# Some legacy migration
|
||||||
mv /data/magisk/stock_boot* /data 2>/dev/null
|
run_migrations
|
||||||
[ -L /data/magisk.img ] || mv /data/magisk.img /data/adb/magisk.img
|
[ -L /data/magisk.img ] || mv /data/magisk.img /data/adb/magisk.img 2>/dev/null
|
||||||
else
|
else
|
||||||
MAGISKBIN=/cache/data_bin
|
MAGISKBIN=/cache/data_bin
|
||||||
fi
|
fi
|
||||||
@ -113,7 +108,6 @@ $BOOTMODE || recovery_actions
|
|||||||
[ -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"
|
||||||
|
|
||||||
find_dtbo_image
|
|
||||||
if [ ! -z $DTBOIMAGE ]; then
|
if [ ! -z $DTBOIMAGE ]; then
|
||||||
ui_print "- Found dtbo image: $DTBOIMAGE"
|
ui_print "- Found dtbo image: $DTBOIMAGE"
|
||||||
# Disable dtbo patch by default
|
# Disable dtbo patch by default
|
||||||
|
@ -34,20 +34,16 @@ fi
|
|||||||
if $BOOTMODE; then
|
if $BOOTMODE; then
|
||||||
# Load utility functions
|
# Load utility functions
|
||||||
. $MAGISKBIN/util_functions.sh
|
. $MAGISKBIN/util_functions.sh
|
||||||
|
BOOTMODE=true
|
||||||
boot_actions
|
boot_actions
|
||||||
mount_partitions
|
mount_partitions
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $MAGISKBIN
|
cd $MAGISKBIN
|
||||||
|
|
||||||
# Find the 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"
|
||||||
|
|
||||||
migrate_boot_backup
|
|
||||||
|
|
||||||
ui_print "- Unpacking boot image"
|
ui_print "- Unpacking boot image"
|
||||||
./magiskboot --unpack "$BOOTIMAGE"
|
./magiskboot --unpack "$BOOTIMAGE"
|
||||||
CHROMEOS=false
|
CHROMEOS=false
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
#MAGISK_VERSION_STUB
|
#MAGISK_VERSION_STUB
|
||||||
SCRIPT_VERSION=$MAGISK_VER_CODE
|
SCRIPT_VERSION=$MAGISK_VER_CODE
|
||||||
|
|
||||||
|
# Detect whether in boot mode
|
||||||
|
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true || BOOTMODE=false
|
||||||
|
$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true
|
||||||
|
$BOOTMODE || id | grep -q 'uid=0' || BOOTMODE=true
|
||||||
|
|
||||||
# Default location, will override if needed
|
# Default location, will override if needed
|
||||||
MAGISKBIN=/data/adb/magisk
|
MAGISKBIN=/data/adb/magisk
|
||||||
[ -z $MOUNTPATH ] && MOUNTPATH=/sbin/.core/img
|
[ -z $MOUNTPATH ] && MOUNTPATH=/sbin/.core/img
|
||||||
@ -47,7 +52,12 @@ mount_partitions() {
|
|||||||
SLOT=_`getprop ro.boot.slot`
|
SLOT=_`getprop ro.boot.slot`
|
||||||
[ $SLOT = "_" ] && SLOT=
|
[ $SLOT = "_" ] && SLOT=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check the boot image to make sure the slot actually make sense
|
||||||
|
find_boot_image
|
||||||
|
find_dtbo_image
|
||||||
[ -z $SLOT ] || ui_print "- A/B partition detected, current slot: $SLOT"
|
[ -z $SLOT ] || ui_print "- A/B partition detected, current slot: $SLOT"
|
||||||
|
|
||||||
ui_print "- Mounting /system, /vendor"
|
ui_print "- Mounting /system, /vendor"
|
||||||
is_mounted /system || [ -f /system/build.prop ] || mount -o ro /system 2>/dev/null
|
is_mounted /system || [ -f /system/build.prop ] || mount -o ro /system 2>/dev/null
|
||||||
if ! is_mounted /system && ! [ -f /system/build.prop ]; then
|
if ! is_mounted /system && ! [ -f /system/build.prop ]; then
|
||||||
@ -105,7 +115,10 @@ find_boot_image() {
|
|||||||
BOOTIMAGE=
|
BOOTIMAGE=
|
||||||
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
|
fi
|
||||||
|
if [ -z "$BOOTIMAGE" ]; then
|
||||||
|
# The slot info is incorrect...
|
||||||
|
SLOT=
|
||||||
for BLOCK in boot_a kern-a android_boot kernel boot lnx bootimg; 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
|
||||||
@ -118,10 +131,10 @@ find_boot_image() {
|
|||||||
[ ! -z $BOOTIMAGE ] && break
|
[ ! -z $BOOTIMAGE ] && break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
BOOTIMAGE=`resolve_link $BOOTIMAGE`
|
[ ! -z "$BOOTIMAGE" ] && BOOTIMAGE=`resolve_link $BOOTIMAGE`
|
||||||
}
|
}
|
||||||
|
|
||||||
migrate_boot_backup() {
|
run_migrations() {
|
||||||
# Update the broken boot backup
|
# Update the broken boot backup
|
||||||
if [ -f /data/stock_boot_.img.gz ]; then
|
if [ -f /data/stock_boot_.img.gz ]; then
|
||||||
$MAGISKBIN/magiskboot --decompress /data/stock_boot_.img.gz /data/stock_boot.img
|
$MAGISKBIN/magiskboot --decompress /data/stock_boot_.img.gz /data/stock_boot.img
|
||||||
@ -134,8 +147,17 @@ migrate_boot_backup() {
|
|||||||
mv /data/stock_boot.img $STOCKDUMP
|
mv /data/stock_boot.img $STOCKDUMP
|
||||||
$MAGISKBIN/magiskboot --compress $STOCKDUMP
|
$MAGISKBIN/magiskboot --compress $STOCKDUMP
|
||||||
fi
|
fi
|
||||||
mv /data/magisk/stock_boot* /data 2>/dev/null
|
# Move the stock backups
|
||||||
mv /data/magisk/adb/stock_boot* /data 2>/dev/null
|
if [ -f /data/magisk/stock_boot* ]; then
|
||||||
|
rm -rf /data/stock_boot*
|
||||||
|
mv /data/magisk/stock_boot* /data 2>/dev/null
|
||||||
|
fi
|
||||||
|
if [ -f /data/adb/magisk/stock_boot* ]; then
|
||||||
|
rm -rf /data/stock_boot*
|
||||||
|
mv /data/adb/magisk/stock_boot* /data 2>/dev/null
|
||||||
|
fi
|
||||||
|
# Remove old dbs
|
||||||
|
rm -f /data/user*/*/magisk.db
|
||||||
}
|
}
|
||||||
|
|
||||||
flash_boot_image() {
|
flash_boot_image() {
|
||||||
|
Loading…
Reference in New Issue
Block a user