feat: auto-install missing prerequisites (go, git, jq)

Install script now detects missing dependencies and installs them
automatically via apt/dnf/yum/pacman/apk/brew. Go is installed
directly from go.dev if missing or too old.

Also added note about global config path in README.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-04 18:06:54 +00:00
parent 3ac04e69a8
commit 842502ca5a
2 changed files with 112 additions and 12 deletions
+4 -1
View File
@@ -31,7 +31,10 @@ curl -fsSL https://gitea.dev.marcus-law.co.il/Chaim/gitea-mcp/raw/branch/main/in
curl -fsSL https://gitea.dev.marcus-law.co.il/Chaim/gitea-mcp/raw/branch/main/install.sh | bash
```
## הגדרה ידנית
## הגדר ידנית
> **חשוב:** כדי שההגדרה תהיה **גלובלית** (זמינה בכל פרויקט), יש לכתוב אותה ב-`~/.claude/settings.json` תחת `mcpServers`.
> אל תשתמשו ב-`.mcp.json` ברמת פרויקט — זה יגרום לכפילויות ויעבוד רק בתיקייה הספציפית.
### שרת יחיד
+108 -11
View File
@@ -66,6 +66,81 @@ ask_input() {
fi
}
# ── Auto-install helpers ───────────────────────────────────────────────────
detect_pkg_manager() {
if command -v apt-get &>/dev/null; then echo "apt"
elif command -v dnf &>/dev/null; then echo "dnf"
elif command -v yum &>/dev/null; then echo "yum"
elif command -v pacman &>/dev/null; then echo "pacman"
elif command -v apk &>/dev/null; then echo "apk"
elif command -v brew &>/dev/null; then echo "brew"
else echo ""; fi
}
install_pkg() {
local pkg="$1"
local pm
pm=$(detect_pkg_manager)
case "$pm" in
apt) sudo apt-get update -qq && sudo apt-get install -y -qq "$pkg" ;;
dnf) sudo dnf install -y -q "$pkg" ;;
yum) sudo yum install -y -q "$pkg" ;;
pacman) sudo pacman -S --noconfirm "$pkg" ;;
apk) sudo apk add --quiet "$pkg" ;;
brew) brew install "$pkg" ;;
*) return 1 ;;
esac
}
install_go() {
local GO_VERSION_TARGET="1.24.2"
local ARCH
ARCH=$(uname -m)
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) error "Unsupported architecture: $ARCH"; return 1 ;;
esac
local OS
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
local TARBALL="go${GO_VERSION_TARGET}.${OS}-${ARCH}.tar.gz"
local URL="https://go.dev/dl/$TARBALL"
info "Downloading Go $GO_VERSION_TARGET for $OS/$ARCH ..."
local tmpfile
tmpfile=$(mktemp)
if command -v curl &>/dev/null; then
curl -fsSL "$URL" -o "$tmpfile"
elif command -v wget &>/dev/null; then
wget -q "$URL" -O "$tmpfile"
else
error "Neither curl nor wget found — cannot download Go"
return 1
fi
info "Installing Go to /usr/local/go ..."
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "$tmpfile"
rm -f "$tmpfile"
# Add to PATH for this session
export PATH="/usr/local/go/bin:$PATH"
# Persist in shell profile if not already there
local profile="$HOME/.profile"
[ -f "$HOME/.bashrc" ] && profile="$HOME/.bashrc"
[ -f "$HOME/.zshrc" ] && profile="$HOME/.zshrc"
if ! grep -q '/usr/local/go/bin' "$profile" 2>/dev/null; then
echo 'export PATH="/usr/local/go/bin:$PATH"' >> "$profile"
info "Added Go to PATH in $profile"
fi
ok "Go $GO_VERSION_TARGET installed"
}
# ── Step 0: Prerequisites ──────────────────────────────────────────────────
echo ""
@@ -74,25 +149,47 @@ echo ""
info "Checking prerequisites..."
if ! command -v go &>/dev/null; then
error "Go is required but not found. Install from https://go.dev/dl/"
exit 1
fi
GO_VERSION=$(go version | grep -oP 'go\d+\.\d+')
ok "go ($GO_VERSION)"
# --- git ---
if ! command -v git &>/dev/null; then
error "git is required but not found"
exit 1
warn "git not found, installing..."
if ! install_pkg git; then
error "Failed to install git. Install manually and re-run."
exit 1
fi
fi
ok "git ($(git --version | cut -d' ' -f3))"
# --- jq ---
if ! command -v jq &>/dev/null; then
error "jq is required but not found. Install: sudo apt install jq"
exit 1
warn "jq not found, installing..."
if ! install_pkg jq; then
error "Failed to install jq. Install manually and re-run."
exit 1
fi
fi
ok "jq ($(jq --version 2>/dev/null))"
# --- Go ---
if ! command -v go &>/dev/null; then
warn "Go not found, installing..."
if ! install_go; then
error "Failed to install Go. Install manually from https://go.dev/dl/ and re-run."
exit 1
fi
fi
GO_VERSION=$(go version | grep -oP 'go\d+\.\d+')
GO_MAJOR=$(echo "$GO_VERSION" | grep -oP '\d+' | head -1)
GO_MINOR=$(echo "$GO_VERSION" | grep -oP '\d+' | tail -1)
if [ "$GO_MAJOR" -lt 1 ] || { [ "$GO_MAJOR" -eq 1 ] && [ "$GO_MINOR" -lt 24 ]; }; then
warn "Go $GO_VERSION is too old (need 1.24+), upgrading..."
if ! install_go; then
error "Failed to upgrade Go. Install manually from https://go.dev/dl/ and re-run."
exit 1
fi
GO_VERSION=$(go version | grep -oP 'go\d+\.\d+')
fi
ok "go ($GO_VERSION)"
# ── Step 1: Clone or update ────────────────────────────────────────────────
echo ""