From 953c40b0831fa992997c69d08712ddba030e4614 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 21 Oct 2019 13:58:57 -0400 Subject: [PATCH] Allow upgrade Magisk daemon in emulator --- scripts/emulator.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/emulator.sh b/scripts/emulator.sh index af7be4a6a..ceb3e8388 100755 --- a/scripts/emulator.sh +++ b/scripts/emulator.sh @@ -36,7 +36,6 @@ if [ ! -f /system/build.prop ]; then else adb push native/out/x86/magiskinit /data/local/tmp fi - adb root || abort 'adb root failed' adb shell sh /data/local/tmp/emulator.sh exit 0 fi @@ -45,12 +44,10 @@ cd /data/local/tmp chmod 777 busybox chmod 777 magiskinit -# Emulator's adb shell should have root -[ `./busybox id -u` -eq 0 ] || abort 'ADB shell should have root access' - -# Check whether already setup -[ -f /sbin/magisk ] && abort "Magisk is already setup" -./busybox pgrep magiskd && abort "Magisk is already setup" +if [ `./busybox id -u` -ne 0 ]; then + # Re-run script with root + exec /system/xbin/su 0 sh $0 +fi # First setup a good env to work with rm -rf bin @@ -59,6 +56,10 @@ rm -rf bin OLD_PATH="$PATH" PATH="/data/local/tmp/bin:$PATH" +# Remove previous setup if exist +pgrep magiskd >/dev/null && pkill -9 magiskd +[ -f /sbin/magisk ] && umount -l /sbin + # SELinux stuffs [ -e /sys/fs/selinux ] && SELINUX=true || SELINUX=false if $SELINUX; then