From 052180eed74d13ffc2e0788d5951e95a3b1614e5 Mon Sep 17 00:00:00 2001 From: erciccione Date: Thu, 12 May 2022 13:22:52 +0200 Subject: [PATCH] deps: updates scripts/haveno_deps.sh - don't overwrite monerod and monero-wallet-rpc if correct archive already downloaded (fixes #239) - delete old monero bins archive and download if checksum doesn't match (fixes #301) --- scripts/haveno_deps.sh | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/scripts/haveno_deps.sh b/scripts/haveno_deps.sh index 50de759a5d..fd7d533977 100755 --- a/scripts/haveno_deps.sh +++ b/scripts/haveno_deps.sh @@ -41,12 +41,10 @@ dw_source() { # Verify Monero hash check_monero() { if is_mac; then - shasum -a 256 -c <<< ''"${MONERO_HASH_MAC}"' *monero-bins-haveno-'"${platform}"'.tar.gz' || exit 1 + shasum -a 256 -c <<< ''"${MONERO_HASH_MAC}"' *monero-bins-haveno-'"${platform}"'.tar.gz' || return 1 else - echo "${MONERO_HASH_LINUX} monero-bins-haveno-${platform}.tar.gz" | sha256sum -c || exit 1 + echo "${MONERO_HASH_LINUX} monero-bins-haveno-${platform}.tar.gz" | sha256sum -c || return 1 fi - - echo "-> Monero binaries downloaded and verified" } # Verify hashes of bitcoind and bitcoin-cli @@ -62,21 +60,37 @@ check_bitcoin() { # Download Monero bins dw_monero() { + + extract_monero() { + echo "-> extracting monerod and monero-wallet-rpc from archive" && \ + tar -xzf "monero-bins-haveno-${platform}.tar.gz" && \ + chmod +x {monerod,monero-wallet-rpc} || exit 1 + } + if is_mac; then platform="mac" else platform="linux" fi - if [ -f monero-bins-haveno-${platform}.tar.gz ]; then - check_monero + if [ -f "monero-bins-haveno-${platform}.tar.gz" ]; then + if check_monero; then + echo "-> Correct Monero archive already downloaded" + if [ ! -f "monerod" ] || [ ! -f "monero-wallet-rpc" ]; then + extract_monero + fi + else + echo "-> Monero archive found but outdated or corrupted. Downloading it again..." && \ + rm monero-bins-haveno-${platform}.tar.gz && \ + dw_source https://github.com/haveno-dex/monero/releases/download/${MONERO_TAG}/monero-bins-haveno-${platform}.tar.gz && \ + check_monero && \ + extract_monero + fi else - dw_source https://github.com/haveno-dex/monero/releases/download/${MONERO_TAG}/monero-bins-haveno-${platform}.tar.gz || { echo "! something went wrong while downloading the Monero binaries. Exiting..."; exit 1; } && \ - check_monero + dw_source https://github.com/haveno-dex/monero/releases/download/${MONERO_TAG}/monero-bins-haveno-${platform}.tar.gz && \ + check_monero && \ + extract_monero fi - - tar -xzf monero-bins-haveno-${platform}.tar.gz && \ - chmod +x {monerod,monero-wallet-rpc} || exit 1 } # Download Bitcoin bins @@ -99,7 +113,6 @@ dw_bitcoin() { rm -r bitcoin-${BTC_VERSION} || exit 1 } - while true; do cd .localnet