#!/bin/sh # Install the tf release binary. Does not clone the repository. # # curl -fsSL https://tweetfactory.sh/install.sh | sh # # The site build copies this file to web/site/dist/install.sh. Binaries and # SHA256SUMS are served from https://tweetfactory.sh/download/, which redirects # to the public release host. GitHub Release assets are not used. # # TF_VERSION=v0.3.0 pin a tag (default: latest) # TF_INSTALL_DIR= default: $HOME/.local/bin set -eu base="https://tweetfactory.sh/download" version="${TF_VERSION:-latest}" dest_dir="${TF_INSTALL_DIR:-$HOME/.local/bin}" os=$(uname -s) arch=$(uname -m) case "$os:$arch" in Darwin:arm64) target="darwin-arm64" ;; Darwin:x86_64) target="darwin-x64" ;; Linux:x86_64|Linux:amd64) target="linux-x64" ;; Linux:aarch64|Linux:arm64) target="linux-arm64" ;; *) echo "install.sh: unsupported platform $os $arch" >&2 echo "Release binaries: darwin-arm64, darwin-x64, linux-x64, linux-arm64." >&2 exit 1 ;; esac asset="tf-$target" if [ "$version" = "latest" ]; then version=$(curl -fsSL "$base/latest/VERSION") version=$(printf '%s' "$version" | tr -d '[:space:]') fi if ! printf '%s\n' "$version" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then echo "install.sh: version must look like v0.3.0 (got ${version})" >&2 exit 1 fi prefix="$base/$version" tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT echo "Downloading $asset ($version)" curl -fsSL "$prefix/$asset" -o "$tmp/$asset" curl -fsSL "$prefix/SHA256SUMS" -o "$tmp/SHA256SUMS" expected=$(grep " ${asset}\$" "$tmp/SHA256SUMS" | awk 'NR==1 { print $1 }' || true) if [ -z "$expected" ]; then echo "install.sh: SHA256SUMS has no entry for $asset" >&2 exit 1 fi if command -v sha256sum >/dev/null 2>&1; then actual=$(sha256sum "$tmp/$asset" | awk '{ print $1 }') elif command -v shasum >/dev/null 2>&1; then actual=$(shasum -a 256 "$tmp/$asset" | awk '{ print $1 }') else echo "install.sh: need sha256sum or shasum to verify the download" >&2 exit 1 fi if [ "$expected" != "$actual" ]; then echo "install.sh: checksum mismatch for $asset" >&2 exit 1 fi mkdir -p "$dest_dir" if command -v install >/dev/null 2>&1; then install -m 755 "$tmp/$asset" "$dest_dir/tf" else cp "$tmp/$asset" "$dest_dir/tf" chmod 755 "$dest_dir/tf" fi echo "Installed $dest_dir/tf" case ":$PATH:" in *":$dest_dir:"*) ;; *) echo "Add $dest_dir to PATH, then open a new shell." ;; esac echo "Next: mkdir a data directory, copy .env.example to .env (tf auth writes the example if it is missing), then run: tf auth"