From 1235c292330b65b7ecbe4dcc889ba6d4b0b3d9c1 Mon Sep 17 00:00:00 2001 From: Ivo Capanema Date: Wed, 9 Nov 2022 00:44:44 -0300 Subject: [PATCH] added check magisk app instead of folder --- reinstall-magisk-on-lineageos | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/reinstall-magisk-on-lineageos b/reinstall-magisk-on-lineageos index 863a052..3e56a72 100755 --- a/reinstall-magisk-on-lineageos +++ b/reinstall-magisk-on-lineageos @@ -139,8 +139,22 @@ reboot_phone() { fastboot -s "$PHONE_ADB_SERIAL_NUMBER" reboot } -check_magisk_folder() { - adb -s "$PHONE_ADB_SERIAL_NUMBER" shell ls /data/adb/magisk/ +check_magisk_app() { + magisk_package_name="com.topjohnwu.magisk" + magisk_package_name_count=$(adb -s "$PHONE_ADB_SERIAL_NUMBER" shell pm list packages "$magisk_package_name" | wc -l) + if [ "${magisk_package_name_count}" -eq 1 ] + then + print_message " [OK] Magisk app seems to be installed on selected phone" + elif [ "${magisk_package_name_count}" -eq 0 ] + then + print_message " [ERROR] Magisk app seems not installed on selected phone. Exiting." + exit -1 + else + print_message " [ERROR] More than one Magisk app entry is present:" + adb -s "$PHONE_ADB_SERIAL_NUMBER" shell pm list packages "$magisk_package_name" + print_message "Exiting." + exit -1 + fi } is_rooted_debugging_enabled() { @@ -152,8 +166,8 @@ main() { check_phone_is_connected print_message "Checking on phone if rooted debugging is enabled" is_rooted_debugging_enabled - print_message "Checking on phone if Magisk folder is present listing /data/adb/magisk/" - check_magisk_folder + print_message "Checking on phone if Magisk is installed" + check_magisk_app print_message "Downloading build archive from $(get_build_url)" download_latest_lineageos_build print_message "Extracting 'boot.img' from build archive in /tmp/boot.img"