Created
April 5, 2026 12:07
-
-
Save seyhunak/6c65298c29fa9171cf01b5f6c17dbe5e to your computer and use it in GitHub Desktop.
One-click installer for a local LLM stack (Gemma 4 + llama.cpp + OpenClaw)
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 | |
| : <<'DOC' | |
| ๐ One-click installer for a local LLM stack (Gemma 4 + llama.cpp + OpenClaw) | |
| What this script does: | |
| - Installs required dependencies (git, cmake, build tools) | |
| - Clones and builds llama.cpp | |
| - Runs a local LLM server using Gemma 4 GGUF model | |
| - Installs OpenClaw (OpenAI-compatible API wrapper) | |
| - Connects OpenClaw to the local model | |
| - Cleans up background processes on exit | |
| Usage: | |
| chmod +x openclaw_gemma4_install.sh | |
| ./openclaw_gemma4_install.sh | |
| Notes: | |
| - Runs server on port 8080 | |
| - Requires Linux (Ubuntu/Debian recommended) | |
| - Ensure enough RAM/CPU for model | |
| DOC | |
| # Exit immediately if any command fails | |
| set -e | |
| echo "๐ Installing local LLM stack..." | |
| # -------------------------------------------------- | |
| # 1. Install required system dependencies | |
| # -------------------------------------------------- | |
| # Check if git is installed; install if missing | |
| if ! command -v git &> /dev/null; then | |
| echo "Installing git..." | |
| sudo apt-get update && sudo apt-get install -y git | |
| fi | |
| # Check if cmake is installed; install build tools if missing | |
| if ! command -v cmake &> /dev/null; then | |
| echo "Installing build tools (cmake, gcc, etc.)..." | |
| sudo apt-get install -y build-essential cmake | |
| fi | |
| # -------------------------------------------------- | |
| # 2. Clone llama.cpp (if not already present) | |
| # -------------------------------------------------- | |
| # Clone repository only if it doesn't exist locally | |
| if [ ! -d "llama.cpp" ]; then | |
| echo "Cloning llama.cpp repository..." | |
| git clone https://github.com/ggerganov/llama.cpp.git | |
| fi | |
| # Move into llama.cpp directory | |
| cd llama.cpp | |
| # Build llama.cpp using CMake (Release mode) | |
| echo "Building llama.cpp..." | |
| cmake -B build | |
| cmake --build build --config Release | |
| # -------------------------------------------------- | |
| # 3. Start local LLM server (llama-server) | |
| # -------------------------------------------------- | |
| echo "Starting llama-server..." | |
| # Run llama-server in background | |
| ./build/bin/llama-server \ | |
| -hf ggml-org/gemma-4-26b-a4b-it-GGUF:Q4_K_M \ # HuggingFace GGUF model | |
| --port 8080 \ # API port | |
| --host 0.0.0.0 & # Bind to all interfaces | |
| # Store process ID for cleanup | |
| SERVER_PID=$! | |
| # Wait for server to initialize (simple delay) | |
| sleep 10 | |
| # -------------------------------------------------- | |
| # 4. Install OpenClaw (OpenAI-compatible interface) | |
| # -------------------------------------------------- | |
| cd .. | |
| # Install OpenClaw if not already available | |
| if ! command -v openclaw &> /dev/null; then | |
| echo "Installing OpenClaw..." | |
| pip install openclaw | |
| fi | |
| # -------------------------------------------------- | |
| # 5. Configure & run OpenClaw | |
| # -------------------------------------------------- | |
| echo "Starting OpenClaw..." | |
| # Connect OpenClaw to local llama.cpp server | |
| openclaw onboard --non-interactive \ | |
| --auth-choice custom-api-key \ # Use custom API key mode | |
| --custom-base-url "http://127.0.0.1:8080/v1" \ # Local LLM endpoint | |
| --custom-model-id "ggml-org-gemma-4-26b-a4b-gguf" \# Model identifier | |
| --custom-api-key "llama.cpp" \ # Dummy API key | |
| --secret-input-mode plaintext \ # No hidden input | |
| --custom-compatibility openai \ # OpenAI-compatible API | |
| --accept-risk # Skip confirmations | |
| # -------------------------------------------------- | |
| # Cleanup: ensure server stops when script exits | |
| # -------------------------------------------------- | |
| # Kill llama-server when script exits (CTRL+C or failure) | |
| trap "echo 'Stopping llama-server...'; kill $SERVER_PID" EXIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment