From 34022f3844c50f448ef05d28e650a83970ca3eca Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 7 Apr 2022 16:24:10 +0300 Subject: [PATCH] add script to fetch bundles --- build/builtin-actors/fetch-bundles.sh | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 build/builtin-actors/fetch-bundles.sh diff --git a/build/builtin-actors/fetch-bundles.sh b/build/builtin-actors/fetch-bundles.sh new file mode 100755 index 000000000..2b3c9704b --- /dev/null +++ b/build/builtin-actors/fetch-bundles.sh @@ -0,0 +1,54 @@ +#!/bin/bash +set -e + +cd $(dirname "$0") + +actors7_cid="" +actors7_hash="" +actors8_cid="bafybeictmywrut5tprz5fnoti6adfwuvixvrfardhqwldxosmdsfavc56e" +actors8_hash="687b38f59b0c32800f55a8f1f303de214ec173c90e653984d67f393bc41c1416" + +die() { + echo "$1" + exit 1 +} + +check() { + file=$1 + hash=$2 + if [ -e "$file" ]; then + file_hash=$(sha256sum "$file" | cut -d ' ' -f 1) + if [ "$file_hash" == "$hash" ]; then + return 0 + else + return 1 + fi + else + return 1 + fi +} + +fetch() { + output=$1 + cid=$2 + hash=$3 + if (check $output $hash); then + return 0 + else + echo "fetching $cid to $output" + curl -k "https://dweb.link/ipfs/$cid" -o $output + check $output $hash || die "hash mismatch" + fi +} + +if [ ! -z "$actors7_cid" ]; then + fetch builtin-actors-v7.car "$actors7_cid" "$actors7_hash" +else + touch builtin-actors-v7.car +fi + +if [ ! -z "$actors8_cid" ]; then + fetch builtin-actors-v8.car "$actors8_cid" "$actors8_hash" +else + touch builtin-actors-v8.car +fi