added build archive exists check

This commit is contained in:
Ivo Oliveira Capanema 2022-11-09 00:52:03 -03:00
parent 49f51d6069
commit 3d156e3161

View File

@ -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"