#!/bin/sh set -e set -u version="${1}" libexec="$(cd "$(dirname "$0")"; pwd)" top="${libexec}/.." src="${2:-"${top}/src"}" sha256sum='ef4928ed381dcb8f5eca9c521b3ffa4a384c75cc76656999e16f5d1c171d8e7b' check_sum() { filename="${1}" expected="${2}" if command -v shasum >/dev/null; then echo "${expected} ${filename}" | shasum -c elif command -v gsha256sum >/dev/null; then echo "${expected} ${filename}" | gsha256sum -c else echo "${expected} ${filename}" | sha256sum -c fi } if [ -f "${src}/node-v${version}.tar.gz" ]; then if check_sum "${src}/node-v${version}.tar.gz" "${sha256sum}"; then exit 0 fi fi platform=$(uname) case "${platform}" in SunOS) CURLOPTS="${CURLOPTS:--k}" ;; *) CURLOPTS="${CURLOPTS:-}" ;; esac mkdir -p "${src}" # shellcheck disable=SC2086 curl ${CURLOPTS} -L -o "${src}/node-v${version}.tar.gz" "https://nodejs.org/dist/v${version}/node-v${version}.tar.gz" check_sum "${src}/node-v${version}.tar.gz" "${sha256sum}" && exit 0