From 8664e9d19ba32fd7280cb3705dc3cb2eecf8ac84 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 28 Aug 2018 22:03:12 -0400 Subject: [PATCH] Update scripts --- scripts/addon.d.sh | 2 +- scripts/flash_script.sh | 2 +- scripts/magisk_uninstaller.sh | 2 +- scripts/util_functions.sh | 21 +++++++++++++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/addon.d.sh b/scripts/addon.d.sh index 844e2658b..52f199fed 100644 --- a/scripts/addon.d.sh +++ b/scripts/addon.d.sh @@ -131,7 +131,7 @@ case "$1" in else initialize OUTFD= - get_outfd + setup_flashable # Run in background, hack for addon.d-v1 (main_v1) & fi diff --git a/scripts/flash_script.sh b/scripts/flash_script.sh index 7168c9a8c..9a039e080 100644 --- a/scripts/flash_script.sh +++ b/scripts/flash_script.sh @@ -31,7 +31,7 @@ fi # Load utility fuctions . $COMMONDIR/util_functions.sh -get_outfd +setup_flashable ########################################################################################## # Detection diff --git a/scripts/magisk_uninstaller.sh b/scripts/magisk_uninstaller.sh index 494341be1..5d9ca0349 100644 --- a/scripts/magisk_uninstaller.sh +++ b/scripts/magisk_uninstaller.sh @@ -30,7 +30,7 @@ fi # Load utility functions . $INSTALLER/util_functions.sh -get_outfd +setup_flashable ui_print "************************" ui_print " Magisk Uninstaller " diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index 6c3127868..c1e13d161 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -10,19 +10,19 @@ #MAGISK_VERSION_STUB # 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 +ps | grep zygote | grep -qv grep && BOOTMODE=true || BOOTMODE=false +$BOOTMODE || ps -A | grep zygote | grep -qv grep && BOOTMODE=true -# Default location, will override if needed -MAGISKBIN=/data/adb/magisk +# Presets +[ -z $NVBASE ] && NVBASE=/data/adb +[ -z $MAGISKBIN ] && MAGISKBIN=$NVBASE/magisk +[ -z $IMG ] && IMG=$NVBASE/magisk.img [ -z $MOUNTPATH ] && MOUNTPATH=/sbin/.core/img -[ -z $IMG ] && IMG=/data/adb/magisk.img BOOTSIGNER="/system/bin/dalvikvm -Xnodex2oat -Xnoimage-dex2oat -cp \$APK com.topjohnwu.magisk.utils.BootSigner" BOOTSIGNED=false -get_outfd() { +setup_flashable() { $BOOTMODE && return # Preserve environment varibles OLD_PATH=$PATH @@ -40,6 +40,11 @@ get_outfd() { fi } +# Backward compatibility +get_outfd() { + setup_flashable +} + ui_print() { $BOOTMODE && echo "$1" || echo -e "ui_print $1\nui_print" >> /proc/self/fd/$OUTFD } @@ -250,7 +255,7 @@ is_mounted() { remove_system_su() { if [ -f /system/bin/su -o -f /system/xbin/su ] && [ ! -f /su/bin/su ]; then - ui_print "! System installed root detected, mount rw :(" + ui_print "- Removing system installed root" mount -o rw,remount /system # SuperSU if [ -e /system/bin/.ext/.su ]; then