Update scripts
This commit is contained in:
parent
eceba26894
commit
0eb79e5acd
@ -117,6 +117,9 @@ chmod -R 755 .
|
|||||||
##########################################################################################
|
##########################################################################################
|
||||||
# Unpack
|
# Unpack
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
|
migrate_boot_backup
|
||||||
|
|
||||||
CHROMEOS=false
|
CHROMEOS=false
|
||||||
|
|
||||||
ui_print_wrap "- Unpacking boot image"
|
ui_print_wrap "- Unpacking boot image"
|
||||||
@ -158,7 +161,7 @@ case $? in
|
|||||||
1 ) # Magisk patched
|
1 ) # Magisk patched
|
||||||
ui_print_wrap "- Magisk patched image detected!"
|
ui_print_wrap "- Magisk patched image detected!"
|
||||||
# Find SHA1 of stock boot image
|
# Find SHA1 of stock boot image
|
||||||
[ -z $SHA1 ] && SHA1=`./magiskboot --cpio-stocksha1 ramdisk.cpio`
|
[ -z $SHA1 ] && SHA1=`./magiskboot --cpio-stocksha1 ramdisk.cpio 2>/dev/null`
|
||||||
OK=false
|
OK=false
|
||||||
./magiskboot --cpio-restore ramdisk.cpio
|
./magiskboot --cpio-restore ramdisk.cpio
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
@ -235,15 +238,6 @@ ui_print_wrap "- Repacking boot image"
|
|||||||
./magiskboot --repack "$BOOTIMAGE" || abort_wrap "! Unable to repack boot image!"
|
./magiskboot --repack "$BOOTIMAGE" || abort_wrap "! Unable to repack boot image!"
|
||||||
|
|
||||||
# Sign chromeos boot
|
# Sign chromeos boot
|
||||||
if $CHROMEOS; then
|
$CHROMEOS && sign_chromeos
|
||||||
echo > empty
|
|
||||||
|
|
||||||
./chromeos/futility vbutil_kernel --pack new-boot.img.signed \
|
|
||||||
--keyblock ./chromeos/kernel.keyblock --signprivate ./chromeos/kernel_data_key.vbprivk \
|
|
||||||
--version 1 --vmlinuz new-boot.img --config empty --arch arm --bootloader empty --flags 0x1
|
|
||||||
|
|
||||||
rm -f empty new-boot.img
|
|
||||||
mv new-boot.img.signed new-boot.img
|
|
||||||
fi
|
|
||||||
|
|
||||||
./magiskboot --cleanup
|
./magiskboot --cleanup
|
||||||
|
@ -113,14 +113,6 @@ 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"
|
||||||
|
|
||||||
# Update our previous backup to new format if exists
|
|
||||||
if [ -f /data/stock_boot.img ]; then
|
|
||||||
SHA1=`$MAGISKBIN/magiskboot --sha1 /data/stock_boot.img 2>/dev/null`
|
|
||||||
STOCKDUMP=/data/stock_boot_${SHA1}.img
|
|
||||||
mv /data/stock_boot.img $STOCKDUMP
|
|
||||||
$MAGISKBIN/magiskboot --compress $STOCKDUMP
|
|
||||||
fi
|
|
||||||
|
|
||||||
SOURCEDMODE=true
|
SOURCEDMODE=true
|
||||||
cd $MAGISKBIN
|
cd $MAGISKBIN
|
||||||
|
|
||||||
|
@ -21,34 +21,13 @@
|
|||||||
#
|
#
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
# Call ui_print_wrap if exists, or else simply use echo
|
|
||||||
# Useful when wrapped in flashable zip
|
|
||||||
ui_print_wrap() {
|
|
||||||
type ui_print >/dev/null 2>&1 && ui_print "$1" || echo "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Call abort if exists, or else show error message and exit
|
|
||||||
# Essential when wrapped in flashable zip
|
|
||||||
abort_wrap() {
|
|
||||||
type abort >/dev/null 2>&1
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
ui_print_wrap "$1"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
abort "$1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
[ -z $BOOTMODE ] && BOOTMODE=false
|
[ -z $BOOTMODE ] && BOOTMODE=false
|
||||||
|
|
||||||
MAGISKBIN=/data/magisk
|
MAGISKBIN=/data/magisk
|
||||||
CHROMEDIR=$MAGISKBIN/chromeos
|
CHROMEDIR=$MAGISKBIN/chromeos
|
||||||
|
|
||||||
# Default permissions
|
|
||||||
umask 022
|
|
||||||
|
|
||||||
if [ ! -f $MAGISKBIN/magiskboot -o ! -f $MAGISKBIN/util_functions.sh ]; then
|
if [ ! -f $MAGISKBIN/magiskboot -o ! -f $MAGISKBIN/util_functions.sh ]; then
|
||||||
ui_print_wrap "! Cannot find $MAGISKBIN"
|
echo "! Cannot find $MAGISKBIN"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -59,89 +38,75 @@ fi
|
|||||||
find_boot_image
|
find_boot_image
|
||||||
[ -z $BOOTIMAGE ] && abort "! Unable to detect boot image"
|
[ -z $BOOTIMAGE ] && abort "! Unable to detect boot image"
|
||||||
|
|
||||||
ui_print_wrap "- Found Boot Image: $BOOTIMAGE"
|
ui_print "- Found Boot Image: $BOOTIMAGE"
|
||||||
|
|
||||||
cd $MAGISKBIN
|
cd $MAGISKBIN
|
||||||
|
|
||||||
ui_print_wrap "- Unpacking boot image"
|
ui_print "- Unpacking boot image"
|
||||||
./magiskboot --unpack "$BOOTIMAGE"
|
./magiskboot --unpack "$BOOTIMAGE"
|
||||||
CHROMEOS=false
|
CHROMEOS=false
|
||||||
case $? in
|
case $? in
|
||||||
1 )
|
1 )
|
||||||
abort_wrap "! Unable to unpack boot image"
|
abort "! Unable to unpack boot image"
|
||||||
;;
|
;;
|
||||||
2 )
|
2 )
|
||||||
CHROMEOS=true
|
CHROMEOS=true
|
||||||
;;
|
;;
|
||||||
3 )
|
3 )
|
||||||
ui_print_wrap "! Sony ELF32 format detected"
|
ui_print "! Sony ELF32 format detected"
|
||||||
abort_wrap "! Please use BootBridge from @AdrianDC to flash Magisk"
|
abort "! Please use BootBridge from @AdrianDC to flash Magisk"
|
||||||
;;
|
;;
|
||||||
4 )
|
4 )
|
||||||
ui_print_wrap "! Sony ELF64 format detected"
|
ui_print "! Sony ELF64 format detected"
|
||||||
abort_wrap "! Stock kernel cannot be patched, please use a custom kernel"
|
abort "! Stock kernel cannot be patched, please use a custom kernel"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Update our previous backup to new format if exists
|
migrate_boot_backup
|
||||||
if [ -f /data/stock_boot.img ]; then
|
|
||||||
SHA1=`./magiskboot --sha1 /data/stock_boot.img 2>/dev/null`
|
|
||||||
STOCKDUMP=/data/stock_boot_${SHA1}.img
|
|
||||||
mv /data/stock_boot.img $STOCKDUMP
|
|
||||||
./magiskboot --compress $STOCKDUMP
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Detect boot image state
|
# Detect boot image state
|
||||||
./magiskboot --cpio-test ramdisk.cpio
|
./magiskboot --cpio-test ramdisk.cpio
|
||||||
case $? in
|
case $? in
|
||||||
0 ) # Stock boot
|
0 ) # Stock boot
|
||||||
ui_print_wrap "- Stock boot image detected!"
|
ui_print "- Stock boot image detected!"
|
||||||
ui_print_wrap "! Magisk is not installed!"
|
abort "! Magisk is not installed!"
|
||||||
exit
|
|
||||||
;;
|
;;
|
||||||
1 ) # Magisk patched
|
1 ) # Magisk patched
|
||||||
ui_print_wrap "- Magisk patched image detected!"
|
ui_print "- Magisk patched image detected!"
|
||||||
# Find SHA1 of stock boot image
|
# Find SHA1 of stock boot image
|
||||||
[ -z $SHA1 ] && SHA1=`./magiskboot --cpio-stocksha1 ramdisk.cpio`
|
[ -z $SHA1 ] && SHA1=`./magiskboot --cpio-stocksha1 ramdisk.cpio 2>/dev/null`
|
||||||
[ ! -z $SHA1 ] && STOCKDUMP=/data/stock_boot_${SHA1}.img
|
[ ! -z $SHA1 ] && STOCKDUMP=/data/stock_boot_${SHA1}.img
|
||||||
if [ -f ${STOCKDUMP}.gz ]; then
|
if [ -f ${STOCKDUMP}.gz ]; then
|
||||||
ui_print_wrap "- Boot image backup found!"
|
ui_print "- Boot image backup found!"
|
||||||
./magiskboot --decompress ${STOCKDUMP}.gz stock_boot.img
|
./magiskboot --decompress ${STOCKDUMP}.gz new-boot.img
|
||||||
else
|
else
|
||||||
ui_print_wrap "! Boot image backup unavailable"
|
ui_print "! Boot image backup unavailable"
|
||||||
ui_print_wrap "- Restoring ramdisk with backup"
|
ui_print "- Restoring ramdisk with internal backup"
|
||||||
./magiskboot --cpio-restore ramdisk.cpio
|
./magiskboot --cpio-restore ramdisk.cpio
|
||||||
./magiskboot --repack $BOOTIMAGE stock_boot.img
|
./magiskboot --repack $BOOTIMAGE new-boot.img
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
2 ) # Other patched
|
2 ) # Other patched
|
||||||
ui_print_wrap "! Boot image patched by other programs!"
|
ui_print "! Boot image patched by other programs!"
|
||||||
abort_wrap "! Cannot uninstall with this uninstaller"
|
abort "! Cannot uninstall"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Sign chromeos boot
|
# Sign chromeos boot
|
||||||
if $CHROMEOS; then
|
$CHROMEOS && sign_chromeos
|
||||||
echo > empty
|
|
||||||
|
|
||||||
./chromeos/futility vbutil_kernel --pack stock_boot.img.signed \
|
ui_print "- Flashing stock/reverted image"
|
||||||
--keyblock ./chromeos/kernel.keyblock --signprivate ./chromeos/kernel_data_key.vbprivk \
|
|
||||||
--version 1 --vmlinuz stock_boot.img --config empty --arch arm --bootloader empty --flags 0x1
|
|
||||||
|
|
||||||
rm -f empty stock_boot.img
|
|
||||||
mv stock_boot.img.signed stock_boot.img
|
|
||||||
fi
|
|
||||||
|
|
||||||
ui_print_wrap "- Flashing stock/reverted image"
|
|
||||||
if [ -L "$BOOTIMAGE" ]; then
|
if [ -L "$BOOTIMAGE" ]; then
|
||||||
dd if=stock_boot.img of="$BOOTIMAGE" bs=4096
|
dd if=new-boot.img of="$BOOTIMAGE" bs=4096
|
||||||
else
|
else
|
||||||
cat stock_boot.img /dev/zero | dd of="$BOOTIMAGE" bs=4096 >/dev/null 2>&1
|
cat new-boot.img /dev/zero | dd of="$BOOTIMAGE" bs=4096 >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
rm -f stock_boot.img
|
rm -f new-boot.img
|
||||||
|
|
||||||
ui_print_wrap "- Removing Magisk files"
|
cd /
|
||||||
|
|
||||||
|
ui_print "- Removing Magisk files"
|
||||||
rm -rf /cache/magisk.log /cache/last_magisk.log /cache/magiskhide.log /cache/.disable_magisk \
|
rm -rf /cache/magisk.log /cache/last_magisk.log /cache/magiskhide.log /cache/.disable_magisk \
|
||||||
/cache/magisk /cache/magisk_merge /cache/magisk_mount /cache/unblock /cache/magisk_uninstaller.sh \
|
/cache/magisk /cache/magisk_merge /cache/magisk_mount /cache/unblock /cache/magisk_uninstaller.sh \
|
||||||
/data/Magisk.apk /data/magisk.apk /data/magisk.img /data/magisk_merge.img /data/magisk_debug.log \
|
/data/Magisk.apk /data/magisk.apk /data/magisk.img /data/magisk_merge.img /data/magisk_debug.log \
|
||||||
/data/busybox /data/magisk /data/custom_ramdisk_patch.sh /data/property/*magisk* \
|
/data/busybox /data/magisk /data/custom_ramdisk_patch.sh /data/property/*magisk* \
|
||||||
/data/app/com.topjohnwu.magisk* /data/user/*/com.topjohnwu.magisk 2>/dev/null
|
/data/app/com.topjohnwu.magisk* /data/user/*/com.topjohnwu.magisk 2>/dev/null
|
||||||
|
@ -30,7 +30,6 @@ fi
|
|||||||
|
|
||||||
# Load utility functions
|
# Load utility functions
|
||||||
. $INSTALLER/util_functions.sh
|
. $INSTALLER/util_functions.sh
|
||||||
|
|
||||||
get_outfd
|
get_outfd
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
@ -65,10 +64,7 @@ if is_mounted /data; then
|
|||||||
# Copy the binaries to /data/magisk, in case they do not exist
|
# Copy the binaries to /data/magisk, in case they do not exist
|
||||||
rm -rf $MAGISKBIN 2>/dev/null
|
rm -rf $MAGISKBIN 2>/dev/null
|
||||||
mkdir -p $MAGISKBIN
|
mkdir -p $MAGISKBIN
|
||||||
cp -af $BINDIR/. $MAGISKBIN
|
cp -af $BINDIR/. $CHROMEDIR $TMPDIR/bin/busybox $INSTALLER/util_functions.sh $MAGISKBIN
|
||||||
cp -af $CHROMEDIR $MAGISKBIN
|
|
||||||
cp -af $TMPDIR/bin/busybox $MAGISKBIN/busybox
|
|
||||||
cp -af $INSTALLER/util_functions.sh $MAGISKBIN
|
|
||||||
chmod -R 755 $MAGISKBIN
|
chmod -R 755 $MAGISKBIN
|
||||||
# Run the acttual uninstallation
|
# Run the acttual uninstallation
|
||||||
recovery_actions
|
recovery_actions
|
||||||
|
@ -73,6 +73,33 @@ find_boot_image() {
|
|||||||
[ -L "$BOOTIMAGE" ] && BOOTIMAGE=`readlink $BOOTIMAGE`
|
[ -L "$BOOTIMAGE" ] && BOOTIMAGE=`readlink $BOOTIMAGE`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
migrate_boot_backup() {
|
||||||
|
# Update the broken boot backup
|
||||||
|
if [ -f /data/stock_boot_.img.gz ]; then
|
||||||
|
./magiskboot --decompress /data/stock_boot_.img.gz
|
||||||
|
mv /data/stock_boot_.img /data/stock_boot.img
|
||||||
|
fi
|
||||||
|
# Update our previous backup to new format if exists
|
||||||
|
if [ -f /data/stock_boot.img ]; then
|
||||||
|
ui_print "- Migrating boot image backup"
|
||||||
|
SHA1=`./magiskboot --sha1 /data/stock_boot.img 2>/dev/null`
|
||||||
|
STOCKDUMP=/data/stock_boot_${SHA1}.img
|
||||||
|
mv /data/stock_boot.img $STOCKDUMP
|
||||||
|
./magiskboot --compress $STOCKDUMP
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
sign_chromeos() {
|
||||||
|
echo > empty
|
||||||
|
|
||||||
|
./chromeos/futility vbutil_kernel --pack new-boot.img.signed \
|
||||||
|
--keyblock ./chromeos/kernel.keyblock --signprivate ./chromeos/kernel_data_key.vbprivk \
|
||||||
|
--version 1 --vmlinuz new-boot.img --config empty --arch arm --bootloader empty --flags 0x1
|
||||||
|
|
||||||
|
rm -f empty new-boot.img
|
||||||
|
mv new-boot.img.signed new-boot.img
|
||||||
|
}
|
||||||
|
|
||||||
is_mounted() {
|
is_mounted() {
|
||||||
if [ ! -z "$2" ]; then
|
if [ ! -z "$2" ]; then
|
||||||
cat /proc/mounts | grep $1 | grep $2, >/dev/null
|
cat /proc/mounts | grep $1 | grep $2, >/dev/null
|
||||||
@ -127,7 +154,6 @@ boot_actions() {
|
|||||||
mount -o bind $MAGISKBIN /dev/magisk/mirror/bin
|
mount -o bind $MAGISKBIN /dev/magisk/mirror/bin
|
||||||
fi
|
fi
|
||||||
MAGISKBIN=/dev/magisk/mirror/bin
|
MAGISKBIN=/dev/magisk/mirror/bin
|
||||||
$MAGISKBIN/magisk magiskpolicy --live "allow fsck * * *"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recovery_actions() {
|
recovery_actions() {
|
||||||
|
Loading…
Reference in New Issue
Block a user