Magisk/scripts/uninstaller_loader.sh

90 lines
2.4 KiB
Bash
Raw Normal View History

2017-06-03 18:03:36 +02:00
#!/sbin/sh
##########################################################################################
#
# Magisk Uninstaller (used in recovery)
# by topjohnwu
#
2017-06-03 18:03:36 +02:00
# This script will load the real uninstaller in a flashable zip
#
##########################################################################################
2017-07-09 18:17:34 +02:00
##########################################################################################
# Preparation
##########################################################################################
2017-06-03 18:03:36 +02:00
2017-07-09 18:17:34 +02:00
BOOTMODE=false
# This path should work in any cases
TMPDIR=/dev/tmp
INSTALLER=$TMPDIR/install
2017-06-03 18:03:36 +02:00
# Default permissions
umask 022
OUTFD=$2
ZIP=$3
2017-07-09 18:17:34 +02:00
if [ ! -f $INSTALLER/util_functions.sh ]; then
echo "! Failed: Unable to extract zip file!"
exit 1
fi
# Load utility functions
. $INSTALLER/util_functions.sh
2017-06-03 18:03:36 +02:00
2017-07-09 18:17:34 +02:00
get_outfd
2017-06-03 18:03:36 +02:00
##########################################################################################
# Main
##########################################################################################
2017-07-09 18:17:34 +02:00
ui_print "************************"
ui_print " Magisk Uninstaller "
ui_print "************************"
2017-06-03 18:03:36 +02:00
2017-07-09 18:17:34 +02:00
ui_print "- Mounting /system, /vendor, /cache, /data"
2017-06-03 18:03:36 +02:00
mount -o ro /system 2>/dev/null
2017-07-09 18:17:34 +02:00
mount -o ro /vendor 2>/dev/null
2017-06-03 18:03:36 +02:00
mount /cache 2>/dev/null
mount /data 2>/dev/null
2017-07-09 18:17:34 +02:00
[ -f /system/build.prop ] || abort "! /system could not be mounted!"
2017-06-03 18:03:36 +02:00
2017-07-09 18:17:34 +02:00
api_level_arch_detect
2017-06-03 18:03:36 +02:00
ui_print "- Device platform: $ARCH"
CHROMEDIR=$INSTALLER/chromeos
BINDIR=$INSTALLER/$ARCH
##########################################################################################
# Detection all done, start installing
##########################################################################################
2017-07-09 18:17:34 +02:00
MAGISKBIN=/data/magisk
if is_mounted /data; then
2017-06-03 18:03:36 +02:00
# Copy the binaries to /data/magisk, in case they do not exist
2017-07-09 18:17:34 +02:00
rm -rf $MAGISKBIN 2>/dev/null
mkdir -p $MAGISKBIN
cp -af $BINDIR/. $MAGISKBIN
cp -af $CHROMEDIR $MAGISKBIN
cp -af $TMPDIR/bin/busybox $MAGISKBIN/busybox
2017-07-09 18:17:34 +02:00
cp -af $INSTALLER/util_functions.sh $MAGISKBIN
chmod -R 755 $MAGISKBIN
# Run the acttual uninstallation
recovery_actions
2017-06-03 18:03:36 +02:00
. $INSTALLER/magisk_uninstaller.sh
2017-07-09 18:17:34 +02:00
recovery_cleanup
2017-06-03 18:03:36 +02: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
umount /system
ui_print "- Rebooting....."
sleep 5
reboot
fi
ui_print "- Done"
exit 0