#!/bin/sh # # No limits for prunednode.today, worldwide fast. # Courtesy of CloudFlare Pages (now free of IPFS, # at least for us on this level) # # This is a shell script which downloads all the files # one by one and joins them to the original latest.zip # for which Stepan's signature of checksum is made. # # For a more advanced example which is decompressing # the ZIP file on the fly using bsdtar which comes from # libarchive-tools, see bsdtar.sh.txt and note that # no signature or checksum verification is being done # there as it all extracts on the fly and does not leave # a file to verify. Use bitcoin-cli gettxoutsetinfo muhash # while having coinstatsindex enabled (the results differ) # to check these data are valid. BTW it would not make # sense to distribute anything alsa but valid Bitcoin data. # # Requirements: wget, cat, rm, sha256sum, grep, ln, gpgv # # Demo: https://asciinema.org/a/532820 URL=https://cfpages-limits.pages.dev # Some functions # # getparts downloads parts and assembles # the latest.zip from them getparts() { test -r files.txt || wget -q $URL/files.txt LINES=$(wc -l files.txt | grep -Eo '[0-9]+') N=0 while read file do N=$((N+1)) echo "Processing file $file... ($((100*$N/$LINES))%)" wget -qO - $URL/$file >> latest.zip done < files.txt } test -w latest.zip && { echo "The file latest.zip already exists." printf "Would you like to overwrite it? [y/N]: " read answer ! test "$answer" = "y" -o "$answer" = "Y" || { > latest.zip false } } || getparts ls latest.zip || exit 1 # Here we assume that latest.zip file is in $PWD # either downloaded now or from previous run F=latest.signed.txt test -s $F || { echo "Downloading $F ..." wget -4 -q $URL/$F || exit 1 } # Check Stephan's signature on the checksum file SIG=ss-specter-release.asc TMP=$(mktemp -d) test -s $SIG || wget -q https://stepansnigirev.com/$SIG test -r $SIG.gpg || gpg --dearmor $SIG gpgv --keyring ./$SIG.gpg $F \ || { echo "Signature not valid! Exiting." >&2; exit 1; } SN=$(grep -oE 'snapshot[0-9]{6}.zip' $F) ln -nfv latest.zip $SN echo "Verifying SHA256 of $SN..." sha256sum -c $F 2>/dev/null && { # Clean up rm -rf $TMP $F ${SIG}* files.txt }