#!/usr/bin/env bash set -euo pipefail usage() { echo "usage: setup.sh [check|hooks]" >&2 exit 2 } action="${1:-check}" [[ "$#" -le 1 ]] || usage [[ "${action}" == "check" || "${action}" == "hooks" ]] || usage missing=() check_command() { local command="$1" label="${2:-$1}" if command -v "${command}" >/dev/null 2>&1; then printf 'ok %s\n' "${label}" else printf 'missing %s\n' "${label}" missing+=("${label}") fi } for command in bash git just tofu lefthook gitleaks caddy podman go wrangler jq node ssh scp ssh-keygen rsync curl dig shellcheck shfmt wg flock; do check_command "${command}" done if [[ -x /usr/lib/systemd/system-generators/podman-system-generator ]]; then printf 'ok %s\n' podman-system-generator else printf 'missing %s\n' podman-system-generator missing+=(podman-system-generator) fi chrome="" for candidate in google-chrome-stable google-chrome chromium chromium-browser; do if command -v "${candidate}" >/dev/null 2>&1; then chrome="${candidate}" break fi done if [[ -n "${chrome}" ]]; then printf 'ok chrome (%s)\n' "${chrome}" else printf 'missing chrome\n' missing+=(chrome) fi if [[ "${#missing[@]}" -ne 0 ]]; then printf '\nmissing %d required tool(s): %s\n' "${#missing[@]}" "${missing[*]}" >&2 exit 1 fi if [[ "${action}" == "hooks" ]]; then lefthook install fi