#!/bin/sh # lamps.sh/install — installs the `lamp` binary. # curl -fsSL https://lamps.sh/install | sh # # What it does, in order: detect OS/arch, download the release binary from GitHub, # verify its sha256, put it in ~/.lamps/bin, tell you how to add that to PATH. # Nothing else. Read it; it is short on purpose. set -eu REPO="synsema/lamp" BASE="https://github.com/${REPO}/releases/latest/download" LAMPS_HOME="${LAMPS_HOME:-$HOME/.lamps}" BIN_DIR="${LAMPS_HOME}/bin" say() { printf '%s\n' "$*"; } die() { printf 'lamp install: %s\n' "$*" >&2; exit 1; } os=$(uname -s | tr '[:upper:]' '[:lower:]') case "$os" in linux) os=linux ;; darwin) os=darwin ;; *) die "unsupported OS: $os (use install.ps1 on Windows)" ;; esac arch=$(uname -m) case "$arch" in x86_64|amd64) arch=x64 ;; arm64|aarch64) arch=arm64 ;; *) die "unsupported architecture: $arch" ;; esac asset="lamp-${os}-${arch}" tmp=$(mktemp -d 2>/dev/null || mktemp -d -t lamp) trap 'rm -rf "$tmp"' EXIT fetch() { if command -v curl >/dev/null 2>&1; then curl -fsSL "$1" -o "$2" elif command -v wget >/dev/null 2>&1; then wget -q "$1" -O "$2" else die "need curl or wget"; fi } say "downloading ${asset} …" fetch "${BASE}/${asset}" "${tmp}/lamp" fetch "${BASE}/${asset}.sha256" "${tmp}/lamp.sha256" expected=$(awk '{print $1}' "${tmp}/lamp.sha256") if command -v sha256sum >/dev/null 2>&1; then actual=$(sha256sum "${tmp}/lamp" | awk '{print $1}') elif command -v shasum >/dev/null 2>&1; then actual=$(shasum -a 256 "${tmp}/lamp" | awk '{print $1}') else die "need sha256sum or shasum to verify the download"; fi [ "$expected" = "$actual" ] || die "sha256 mismatch: expected $expected, got $actual" mkdir -p "$BIN_DIR" install -m 755 "${tmp}/lamp" "${BIN_DIR}/lamp" 2>/dev/null || { cp "${tmp}/lamp" "${BIN_DIR}/lamp"; chmod 755 "${BIN_DIR}/lamp"; } say "installed ${BIN_DIR}/lamp" case ":$PATH:" in *":${BIN_DIR}:"*) ;; *) shell_name=$(basename "${SHELL:-sh}") case "$shell_name" in zsh) rc="$HOME/.zshrc" ;; bash) rc="$HOME/.bashrc" ;; fish) rc="$HOME/.config/fish/config.fish" ;; *) rc="$HOME/.profile" ;; esac if [ "$shell_name" = fish ]; then line="set -gx PATH \$PATH ${BIN_DIR}" else line="export PATH=\"\$PATH:${BIN_DIR}\"" fi if [ -w "$(dirname "$rc")" ] && ! grep -qs "$BIN_DIR" "$rc" 2>/dev/null; then printf '\n# lamps\n%s\n' "$line" >> "$rc" say "added ${BIN_DIR} to PATH in ${rc} — open a new shell, or run:" else say "add ${BIN_DIR} to your PATH:" fi say " $line" ;; esac say "" say "next — nothing is pulled yet; every lamp is one pull away:" say " lamp pull git read-only git, from github.com/synsema/lamps" say " cd " say " lamp git log runs under stdout,env=LAMP_*,exec=git — nothing else" say " lamp list what is here, and whether agents get it"