mirror of
https://github.com/fluencelabs/node-distro
synced 2025-05-29 23:51:23 +00:00
36 lines
840 B
Bash
Executable File
36 lines
840 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -o pipefail -o errexit -o nounset
|
|
|
|
CONFIG="${1:-services.json}"
|
|
|
|
BUILTINS_DIR=/builtins/
|
|
TMP_BUILTINS=./tmp/builtins
|
|
|
|
mkdir -p $BUILTINS_DIR
|
|
mkdir -p $TMP_BUILTINS
|
|
|
|
jq -r '
|
|
to_entries | .[] | .key, .value.url, .value.sha256, .value.version
|
|
' $CONFIG |
|
|
while
|
|
read -r name
|
|
read -r url
|
|
read -r sha256
|
|
read -r version
|
|
do
|
|
echo "*** download $name@$version ***"
|
|
TAR="$TMP_BUILTINS/${name}.tar.gz"
|
|
# TODO: use --fail-with-body
|
|
curl -sL --fail $url -o $TAR || (
|
|
echo "failed to download $url" >&2
|
|
exit 1
|
|
)
|
|
echo "$sha256 $TAR" | sha256sum --check --status || (
|
|
echo "incorrect SHA256 for $name" >&2
|
|
exit 1
|
|
)
|
|
tar -C $BUILTINS_DIR -xf $TAR
|
|
done
|
|
|
|
rm -rf $TMP_BUILTINS
|