2017-06-03 16:03:36 +00:00
|
|
|
#!/sbin/sh
|
|
|
|
##########################################################################################
|
|
|
|
#
|
|
|
|
# Magisk Uninstaller (used in recovery)
|
|
|
|
# by topjohnwu
|
2017-08-01 18:21:50 +00:00
|
|
|
#
|
2017-06-03 16:03:36 +00:00
|
|
|
# This script will load the real uninstaller in a flashable zip
|
|
|
|
#
|
|
|
|
##########################################################################################
|
|
|
|
|
2017-07-09 16:17:34 +00:00
|
|
|
##########################################################################################
|
|
|
|
# Preparation
|
|
|
|
##########################################################################################
|
2017-06-03 16:03:36 +00:00
|
|
|
|
2017-07-09 16:17:34 +00:00
|
|
|
BOOTMODE=false
|
2017-08-01 18:21:50 +00:00
|
|
|
# This path should work in any cases
|
|
|
|
TMPDIR=/dev/tmp
|
|
|
|
|
|
|
|
INSTALLER=$TMPDIR/install
|
2017-06-03 16:03:36 +00:00
|
|
|
# Default permissions
|
|
|
|
umask 022
|
|
|
|
|
|
|
|
OUTFD=$2
|
|
|
|
ZIP=$3
|
|
|
|
|
2017-07-09 16:17:34 +00:00
|
|
|
if [ ! -f $INSTALLER/util_functions.sh ]; then
|
2017-09-15 19:48:58 +00:00
|
|
|
echo "! Unable to extract zip file!"
|
2017-07-09 16:17:34 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Load utility functions
|
|
|
|
. $INSTALLER/util_functions.sh
|
|
|
|
get_outfd
|
2017-06-03 16:03:36 +00:00
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Main
|
|
|
|
##########################################################################################
|
|
|
|
|
2017-07-09 16:17:34 +00:00
|
|
|
ui_print "************************"
|
|
|
|
ui_print " Magisk Uninstaller "
|
|
|
|
ui_print "************************"
|
2017-06-03 16:03:36 +00:00
|
|
|
|
2017-09-27 07:26:21 +00:00
|
|
|
is_mounted /data || mount /data || abort "! Unable to mount partitions"
|
|
|
|
is_mounted /cache || mount /cache 2>/dev/null
|
2017-09-15 19:48:58 +00:00
|
|
|
mount_partitions
|
2017-06-03 16:03:36 +00:00
|
|
|
|
2017-07-09 16:17:34 +00:00
|
|
|
api_level_arch_detect
|
2017-06-03 16:03:36 +00:00
|
|
|
|
|
|
|
ui_print "- Device platform: $ARCH"
|
|
|
|
CHROMEDIR=$INSTALLER/chromeos
|
|
|
|
BINDIR=$INSTALLER/$ARCH
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Detection all done, start installing
|
|
|
|
##########################################################################################
|
|
|
|
|
2017-07-09 16:17:34 +00:00
|
|
|
if is_mounted /data; then
|
2017-09-27 07:26:21 +00:00
|
|
|
recovery_actions
|
2017-09-15 19:48:58 +00:00
|
|
|
# Save our stock boot image dump before removing it
|
2017-09-27 07:26:21 +00:00
|
|
|
mv $MAGISKBIN/stock_boot* /data 2>/dev/null
|
2017-06-03 16:03:36 +00:00
|
|
|
# Copy the binaries to /data/magisk, in case they do not exist
|
2017-07-09 16:17:34 +00:00
|
|
|
rm -rf $MAGISKBIN 2>/dev/null
|
|
|
|
mkdir -p $MAGISKBIN
|
2017-09-06 08:13:23 +00:00
|
|
|
cp -af $BINDIR/. $CHROMEDIR $TMPDIR/bin/busybox $INSTALLER/util_functions.sh $MAGISKBIN
|
2017-07-09 16:17:34 +00:00
|
|
|
chmod -R 755 $MAGISKBIN
|
2017-09-27 07:26:21 +00:00
|
|
|
# Run the actual uninstallation
|
2017-06-03 16:03:36 +00:00
|
|
|
. $INSTALLER/magisk_uninstaller.sh
|
2017-09-27 07:26:21 +00:00
|
|
|
recovery_cleanup
|
2017-06-03 16:03:36 +00:00
|
|
|
else
|
|
|
|
ui_print "! Data unavailable"
|
|
|
|
ui_print "! Placing uninstall script to /cache"
|
|
|
|
ui_print "! The device might reboot multiple times"
|
|
|
|
cp -af $INSTALLER/magisk_uninstaller.sh /cache/magisk_uninstaller.sh
|
|
|
|
ui_print "- Rebooting....."
|
|
|
|
sleep 5
|
|
|
|
reboot
|
|
|
|
fi
|
|
|
|
|
|
|
|
ui_print "- Done"
|
|
|
|
exit 0
|