From 3d156e316138c051b2acdd03f741029237a7ee4e Mon Sep 17 00:00:00 2001 From: Ivo Capanema Date: Wed, 9 Nov 2022 00:52:03 -0300 Subject: [PATCH] added build archive exists check --- reinstall-magisk-on-lineageos | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/reinstall-magisk-on-lineageos b/reinstall-magisk-on-lineageos index 086f9d4..6fc9576 100755 --- a/reinstall-magisk-on-lineageos +++ b/reinstall-magisk-on-lineageos @@ -42,6 +42,15 @@ get_build_url() { head -1 } +check_exists_latest_lineageos_build() { + # The --location lets curl follow the redirection. + curl --location "$(get_build_url)?sha256" --output /tmp/lineageos.sha256 + hash1=$( awk '{print $1}' lineageos.sha256 ) + hash2=$( sha256sum lineageos.zip | awk '{print $1}' ) + [[ "$hash1" =~ "$hash2" ]] + return +} + download_latest_lineageos_build() { # The --location lets curl follow the redirection. curl --location "$(get_build_url)" --output /tmp/lineageos.zip @@ -163,8 +172,12 @@ main() { is_rooted_debugging_enabled 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 + if check_exists_latest_lineageos_build; then + print_message "Build archive already exists, skipping download" + else + print_message "Downloading build archive from $(get_build_url)" + download_latest_lineageos_build + fi print_message "Extracting 'boot.img' from build archive in /tmp/boot.img" extract_boot_image print_message "Copying from PC to phone the boot image in /sdcard/Download/boot.img"