|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +LOCAL_INSTALL_PATH="/opt/clawdbot-install.sh" |
| 5 | +if [[ -n "${CLAWDBOT_INSTALL_URL:-}" ]]; then |
| 6 | + INSTALL_URL="$CLAWDBOT_INSTALL_URL" |
| 7 | +elif [[ -f "$LOCAL_INSTALL_PATH" ]]; then |
| 8 | + INSTALL_URL="file://${LOCAL_INSTALL_PATH}" |
| 9 | +else |
| 10 | + INSTALL_URL="https://clawd.bot/install.sh" |
| 11 | +fi |
| 12 | + |
| 13 | +echo "==> Clone Clawdbot repo" |
| 14 | +REPO_DIR="/tmp/clawdbot-src" |
| 15 | +rm -rf "$REPO_DIR" |
| 16 | +git clone --depth 1 https://github.com/clawdbot/clawdbot.git "$REPO_DIR" |
| 17 | + |
| 18 | +echo "==> Verify autodetect fails without explicit method (no TTY)" |
| 19 | +( |
| 20 | + cd "$REPO_DIR" |
| 21 | + set +e |
| 22 | + curl -fsSL "$INSTALL_URL" | bash -s -- --dry-run --no-onboard --no-prompt >/tmp/git-detect.out 2>&1 |
| 23 | + code=$? |
| 24 | + set -e |
| 25 | + if [[ "$code" -eq 0 ]]; then |
| 26 | + echo "ERROR: expected installer to fail when repo is detected but no method selected" >&2 |
| 27 | + cat /tmp/git-detect.out >&2 |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | +) |
| 31 | + |
| 32 | +echo "==> Install from Git (using detected checkout)" |
| 33 | +( |
| 34 | + cd "$REPO_DIR" |
| 35 | + curl -fsSL "$INSTALL_URL" | bash -s -- --install-method git --no-onboard --no-prompt --no-git-update |
| 36 | +) |
| 37 | + |
| 38 | +echo "==> Verify wrapper exists" |
| 39 | +test -x "$HOME/.local/bin/clawdbot" |
| 40 | + |
| 41 | +echo "==> Verify clawdbot runs" |
| 42 | +export PATH="$HOME/.local/bin:$PATH" |
| 43 | +clawdbot --help >/dev/null |
| 44 | + |
| 45 | +echo "==> Verify version matches checkout" |
| 46 | +EXPECTED_VERSION="$(node -e "console.log(JSON.parse(require('fs').readFileSync('${REPO_DIR}/package.json','utf8')).version)")" |
| 47 | +INSTALLED_VERSION="$(clawdbot --version 2>/dev/null | head -n 1 | tr -d '\r')" |
| 48 | +echo "installed=$INSTALLED_VERSION expected=$EXPECTED_VERSION" |
| 49 | +if [[ "$INSTALLED_VERSION" != "$EXPECTED_VERSION" ]]; then |
| 50 | + echo "ERROR: expected clawdbot@$EXPECTED_VERSION, got $INSTALLED_VERSION" >&2 |
| 51 | + exit 1 |
| 52 | +fi |
| 53 | + |
| 54 | +echo "OK" |
| 55 | + |
0 commit comments