diff --git a/lib.sh b/lib.sh index 2b4af5af..9f37fcff 100644 --- a/lib.sh +++ b/lib.sh @@ -1264,27 +1264,32 @@ else msg_box "There seems to be an issue with your network, please try again later.\nThis script will now exit." exit 1 fi -# Checksum of the downloaded file -print_text_in_color "$ICyan" "Checking SHA256 checksum..." -mkdir -p "$SHA256_DIR" -curl_to_dir "$NCREPO" "$STABLEVERSION.tar.bz2.sha256" "$SHA256_DIR" -SHA256SUM="$(tail "$SHA256_DIR"/"$STABLEVERSION".tar.bz2.sha256 | awk '{print$1}')" -if ! echo "$SHA256SUM" "$STABLEVERSION.tar.bz2" | sha256sum -c + +if ! [ -f /tmp/prerelease.version ] then - msg_box "The SHA256 checksums of $STABLEVERSION.tar.bz2 didn't match, please try again." - exit 1 + # Checksum of the downloaded file + print_text_in_color "$ICyan" "Checking SHA256 checksum..." + mkdir -p "$SHA256_DIR" + curl_to_dir "$NCREPO" "$STABLEVERSION.tar.bz2.sha256" "$SHA256_DIR" + SHA256SUM="$(tail "$SHA256_DIR"/"$STABLEVERSION".tar.bz2.sha256 | awk '{print$1}')" + if ! echo "$SHA256SUM" "$STABLEVERSION.tar.bz2" | sha256sum -c + then + msg_box "The SHA256 checksums of $STABLEVERSION.tar.bz2 didn't match, please try again." + exit 1 + fi + # integrity of the downloaded file + print_text_in_color "$ICyan" "Checking GPG integrity..." + install_if_not gnupg + mkdir -p "$GPGDIR" + curl_to_dir "$NCREPO" "$STABLEVERSION.tar.bz2.asc" "$GPGDIR" + chmod -R 600 "$GPGDIR" + gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys "$OpenPGP_fingerprint" + gpg --verify "$GPGDIR/$STABLEVERSION.tar.bz2.asc" "$HTML/$STABLEVERSION.tar.bz2" + rm -r "$SHA256_DIR" + rm -r "$GPGDIR" + rm -f releases + rm -f /tmp/prerelease.version fi -# integrity of the downloaded file -print_text_in_color "$ICyan" "Checking GPG integrity..." -install_if_not gnupg -mkdir -p "$GPGDIR" -curl_to_dir "$NCREPO" "$STABLEVERSION.tar.bz2.asc" "$GPGDIR" -chmod -R 600 "$GPGDIR" -gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys "$OpenPGP_fingerprint" -gpg --verify "$GPGDIR/$STABLEVERSION.tar.bz2.asc" "$HTML/$STABLEVERSION.tar.bz2" -rm -r "$SHA256_DIR" -rm -r "$GPGDIR" -rm -f releases } # call like: download_script folder_variable name_of_script diff --git a/nextcloud_update.sh b/nextcloud_update.sh index c8c61f58..f481b10d 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -704,13 +704,11 @@ as it's not currently possible to downgrade.\n\nPlease only continue if you have NCREPO="https://download.nextcloud.com/server/prereleases" NCVERSION=$(curl -s -m 900 $NCREPO/ | sed --silent 's/.*href="nextcloud-\([^"]\+\).zip.asc".*/\1/p' | sort --version-sort | tail -1) STABLEVERSION="nextcloud-$NCVERSION" - rm -f /tmp/prerelease.version elif grep -q RC /tmp/prerelease.version then NCREPO="https://download.nextcloud.com/server/prereleases" NCVERSION=$(cat /tmp/prerelease.version) STABLEVERSION="nextcloud-$NCVERSION" - rm -f /tmp/prerelease.version fi fi fi