installer: fix and harden the curl|sh installer, add serving Worker#4
Merged
Conversation
scripts/install.sh never worked against real releases: - it built an unversioned archive name (pg_hardstorage_<os>_<arch>.tar.gz) but goreleaser emits pg_hardstorage_<version>_<os>_<arch>.tar.gz → 404; - it used `latest` as a literal download path (no such tag) → 404; - it read $1 directly, so `--version <tag>` was taken as the version string verbatim. Resolve `latest` via the GitHub release redirect, build the versioned goreleaser archive name, and parse --version/--bindir/--no-verify properly. Verify downloads by SHA-256 against checksums.txt, and by cosign signature when cosign is present. Re-exec under bash (the canonical `| sh` entry runs dash on Debian) and fall back to ~/.local/bin when there's no TTY to prompt for sudo. Add a Cloudflare Worker (deploy/cloudflare/) that serves the script at get.pghardstorage.org, with a wrangler.toml wired for the Cloudflare Git integration and the custom-domain route. Verified against the live v1.0.0 release: latest resolves to v1.0.0, the built archive name matches checksums.txt, and the tarball + .sig + .pem all exist.
The bash re-exec guard could never recover bash for the canonical `curl -sSL ... | sh` path: a piped script has no file on disk, so $0 is the shell binary (e.g. /usr/bin/dash) and `exec bash "$0"` becomes `exec bash /usr/bin/dash` — "cannot execute binary file", exit 126. That broke the very invocation the PR set out to fix. Drop the re-exec and convert the script to strict POSIX sh (no [[ ]], no =~, no `set -o pipefail`), so it runs unchanged under dash, busybox ash, and bash. usage() now prints a static heredoc instead of sed-ing $0 (which isn't a file when piped). Verified end-to-end under dash: latest→v1.0.0, versioned archive name, SHA-256 verify, extract, install.
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
scripts/install.sh never worked against real releases:
latestas a literal download path (no such tag) → 404;--version <tag>was taken as the version string verbatim.Resolve
latestvia the GitHub release redirect, build the versioned goreleaser archive name, and parse --version/--bindir/--no-verify properly. Verify downloads by SHA-256 against checksums.txt, and by cosign signature when cosign is present. Re-exec under bash (the canonical| shentry runs dash on Debian) and fall back to ~/.local/bin when there's no TTY to prompt for sudo.Add a Cloudflare Worker (deploy/cloudflare/) that serves the script at get.pghardstorage.org, with a wrangler.toml wired for the Cloudflare Git integration and the custom-domain route.
Verified against the live v1.0.0 release: latest resolves to v1.0.0, the built archive name matches checksums.txt, and the tarball + .sig + .pem all exist.
Summary
Make
curl -sSL https://get.pghardstorage.org | shactually work: fix three bugs inscripts/install.sh(unversioned archive name,latestas a literal path, and broken--versionparsing), add SHA-256 + cosign verification, and add a Cloudflare Worker (deploy/cloudflare/) that serves the script atget.pghardstorage.org.Type
Tests
make checkpasses locally (vet + race tests)make test-integration) where touchedCompatibility
Checklist
Author: Hans-Jürgen Schönig <hs@cybertec.at>)