Last active
April 17, 2026 19:45
-
-
Save kristovatlas/544b2d7a8314cf21c67e33b5a081695a to your computer and use it in GitHub Desktop.
Install Claude Code based on known-good hash instead of curl-bashing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # ── Helpers ────────────────────────────────────────────────────── | |
| info() { printf '\033[1;34m[INFO]\033[0m %s\n' "$*"; } | |
| ok() { printf '\033[1;32m[OK]\033[0m %s\n' "$*"; } | |
| err() { printf '\033[1;31m[ERROR]\033[0m %s\n' "$*" >&2; } | |
| # ── Pre-flight: require npm ────────────────────────────────────── | |
| if ! command -v npm &>/dev/null; then | |
| err "npm is not installed. Please install Node.js/npm first." | |
| exit 1 | |
| fi | |
| info "Node $(node -v) / npm $(npm -v)" | |
| # ── Check for Socket Firewall (sfw) ───────────────────────────── | |
| if command -v sfw &>/dev/null; then | |
| ok "Socket Firewall is already installed: $(sfw --version 2>/dev/null || echo 'version unknown')" | |
| else | |
| info "Socket Firewall not found. Installing globally via npm..." | |
| npm i -g sfw | |
| # Verify the install succeeded | |
| if command -v sfw &>/dev/null; then | |
| ok "Socket Firewall installed successfully." | |
| else | |
| err "sfw command not found after install. Check that npm's global bin directory is in your PATH." | |
| err "Hint: npm config get prefix → add <prefix>/bin to your PATH" | |
| exit 1 | |
| fi | |
| fi | |
| # ── Clear npm cache (recommended by Socket before first use) ───── | |
| info "Clearing npm cache so sfw can intercept all network requests..." | |
| npm cache clean --force | |
| # ── Run the guarded install ────────────────────────────────────── | |
| info "Running: sfw npm i -g @openai/codex" | |
| sfw npm i -g @openai/codex | |
| ok "Done! @openai/codex installed with Socket Firewall protection." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -fsSL https://claude.ai/install.sh -o install.sh && checksum="$(sha256sum install.sh | awk '{print $1}')" | |
| if [ "$checksum" = "b315b46925a9bfb9422f2503dd5aa649f680832f4c076b22d87c39d578c3d830" ]; then | |
| echo "Checksum matched." | |
| echo "Proceed with installation? (Y/n)" | |
| read response | |
| if [ "$response" = "Y" ] || [ "$response" = "y" ] || [ -z "$response" ]; then bash install.sh; else | |
| echo "Installation aborted." | |
| rm -f install.sh | |
| exit 0 | |
| fi | |
| else | |
| echo "Error: Checksum failed" | |
| rm -f install.sh | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -fsSL https://claude.ai/install.sh -o install.sh && checksum="$(sha256sum install.sh | awk '{print $1}')"; if [ "$checksum" = "b315b46925a9bfb9422f2503dd5aa649f680832f4c076b22d87c39d578c3d830" ]; then echo "Checksum matched."; echo "Proceed with installation? (Y/n)"; read response; if [ "$response" = "Y" ] || [ "$response" = "y" ] || [ -z "$response" ]; then bash install.sh; else echo "Installation aborted."; rm -f install.sh; exit 0; fi; else echo "Error: Checksum failed"; rm -f install.sh; exit 1; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment