Files
openclaw2/scripts/install-cli-tools.sh

44 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Idempotent installer for required CLIs: ripgrep, pnpm (node/npm), gh, jq
# Designed for Debian/Ubuntu. Run with sudo for system installs.
which rg >/dev/null 2>&1 || {
echo "Installing ripgrep..."
apt-get update && apt-get install -y ripgrep
}
which jq >/dev/null 2>&1 || {
echo "Installing jq..."
apt-get update && apt-get install -y jq
}
which gh >/dev/null 2>&1 || {
echo "Installing gh (GitHub CLI)..."
apt-get update && apt-get install -y gh
}
# Ensure node is present (use nvm or apt). Prefer node >=16.
if ! command -v node >/dev/null 2>&1; then
echo "Node.js not found. Installing Node 18 LTS..."
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs
fi
# pnpm
if ! command -v pnpm >/dev/null 2>&1; then
echo "Installing pnpm..."
npm install -g pnpm || true
fi
echo "Verifying installs..."
for cmd in rg jq gh node pnpm npm; do
if command -v "$cmd" >/dev/null 2>&1; then
echo "OK: $cmd -> $(command -v $cmd)"
else
echo "MISSING: $cmd"
fi
done
echo "Done."