#!/usr/bin/env bash # CAW Protocol installer. # # This script bootstraps a brand-new Debian/Ubuntu host into a working CAW node. # It installs every system dep (Node, Postgres, Redis, Elasticsearch, nginx, # pm2, certbot), creates a non-root `caw` user, clones the repo, and hands off # to the interactive Node CLI for configuration + service start. # # Usage: # /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/GilgameshCaw/Caw/master/install.sh)" # # Or local: # sudo bash install.sh # # Environment overrides: # CAW_DIR — install directory (default: /var/www/caw) # CAW_REPO — git remote (default: https://github.com/GilgameshCaw/Caw.git) # CAW_USER — system user that will own the install (default: caw) # CAW_BRANCH — branch to check out (default: master) # SKIP_BOOTSTRAP=1 — skip apt installs (assume system deps already there) # CAW_REUSE_ENV — path to a previous install's .env to reuse values from. # Auto-detects $CAW_DIR/client/.env if it exists. Set to # "0" to disable auto-detection and re-prompt everything. set -euo pipefail # ---------- Colors ----------------------------------------------------------- # ANSI-C quoting ($'...') so the escape bytes are real, not the literal string # "\033[1;33m". This lets us use the vars inside `cat` heredocs without needing # echo -e / printf for every line. GOLD=$'\033[1;33m' GREEN=$'\033[0;32m' RED=$'\033[0;31m' DIM=$'\033[2m' RESET=$'\033[0m' log() { echo -e " $*"; } ok() { echo -e " ${GREEN}✓${RESET} $*"; } warn() { echo -e " ${GOLD}!${RESET} $*"; } err() { echo -e " ${RED}✗${RESET} $*" >&2; } step() { echo; echo -e "${GOLD}▸${RESET} $*"; } # Run a command quietly. Stdout goes to /tmp/caw-install.log (so apt's # unpacking spam doesn't drown the user); stderr stays attached so real errors # surface in real time. On failure, dump the last 30 lines of the log so the # operator has something to debug with. Usage: quiet