seahaven-door-unlock-api/terraform/build_packages_external.sh

26 lines
666 B
Bash
Raw Normal View History

#!/usr/bin/env bash
# Terraform external data source entrypoint. Stdout must be JSON only.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
# artifacts.tf already launches this file with bash, so +x is not required
# here. Invoke the inner script the same way so HCP plan does not depend on
# the git executable bit.
bash "${ROOT}/build_packages.sh" >&2
if command -v sha256sum >/dev/null 2>&1; then
SHA=(sha256sum)
else
SHA=(shasum -a 256)
fi
hash="$(
{
find -P "${ROOT}/build" -type f -print0 2>/dev/null \
| sort -z \
| xargs -0 "${SHA[@]}"
} | "${SHA[@]}" | awk '{print $1}'
)"
printf '{"status":"ok","hash":"%s"}\n' "${hash}"