-
Notifications
You must be signed in to change notification settings - Fork 1
/
latest.sh.txt
75 lines (70 loc) · 2.16 KB
/
latest.sh.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/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
}