#!/usr/bin/env bash # EcoFold one-line installer for Linux: # # curl -fsSL https://raw.githubusercontent.com/Stellexd/ecofold/v0.1.0-preview.5/install.sh | bash # # It downloads ecofold-setup from the GitHub release, checks its SHA-256 # against the checksum published with it, and runs it. ecofold-setup asks for # sudo by itself; this script never does. Arguments after `bash -s --` are # passed to ecofold-setup (for example `-yes` or `-uninstall`). # # Everything runs inside main(), so a download cut halfway runs nothing. main() { set -euo pipefail local version="${ECOFOLD_VERSION:-v0.1.0-preview.5}" local base="https://github.com/Stellexd/ecofold/releases/download/${version}" if [ "$(uname -s)" != "Linux" ] || [ "$(uname -m)" != "x86_64" ]; then echo "EcoFold's installer is for Linux on x86_64 PCs." >&2 exit 1 fi for tool in curl sha256sum; do if ! command -v "$tool" >/dev/null 2>&1; then echo "This installer needs $tool." >&2 exit 1 fi done if [ "$(id -u)" -eq 0 ]; then echo "Run this as your normal user, without sudo: the installer asks for the password itself." >&2 exit 1 fi # The installer asks questions. Under `curl | bash` standard input is the # script itself, so the answers are read from the terminal instead. if ! { : /dev/null; then echo "No terminal to answer the installer's questions; download ecofold-setup and run it with -yes." >&2 exit 1 fi # Global, not local: the EXIT trap runs after main has returned. ECOFOLD_TMP="$(mktemp -d "${XDG_CACHE_HOME:-$HOME/.cache}/ecofold-install.XXXXXX" 2>/dev/null || mktemp -d)" trap 'rm -rf -- "${ECOFOLD_TMP:?}"' EXIT local dir="$ECOFOLD_TMP" echo "Downloading EcoFold ${version}..." curl -fL --proto '=https' --tlsv1.2 --progress-bar -o "$dir/ecofold-setup" "$base/ecofold-setup" curl -fsSL --proto '=https' --tlsv1.2 -o "$dir/ecofold-setup.sha256" "$base/ecofold-setup.sha256" (cd "$dir" && sha256sum --check --status ecofold-setup.sha256) || { echo "The download does not match its published SHA-256; nothing was installed." >&2 exit 1 } echo "Download verified." chmod +x "$dir/ecofold-setup" "$dir/ecofold-setup" "$@"