Last active
July 1, 2025 05:18
-
-
Save casjay/c736550d571e15e989c256276e7fd73d to your computer and use it in GitHub Desktop.
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 | |
| # | |
| # π§ Script Name : install-llm-suite.sh | |
| # π¦ Description : Binary installs of Ollama, OpenWebUI, and OpenDiffusion | |
| # π Created : 2025-07-01 | |
| # π§Ύ License : MIT | |
| # π§© Version : 2025.07.01 | |
| # π₯οΈ Supported OS : macOS, Linux (All major distros) | |
| # π XDG Fallback : Yes | |
| # π οΈ Systemd Integration : Yes (system preferred, user fallback) | |
| # π Requires Privileges : Optional (auto-detects system/user fallback) | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| VERSION="2025.07.01" | |
| DEBUG=false | |
| OS=$(uname -s) | |
| ARCH_RAW=$(uname -m) | |
| UNINSTALL=false | |
| # Normalize architecture | |
| case "$ARCH_RAW" in | |
| x86_64) ARCH="amd64" ;; | |
| aarch64|arm64) ARCH="arm64" ;; | |
| *) echo "Unsupported architecture: $ARCH_RAW" >&2; exit 1 ;; | |
| esac | |
| # Binary URLs | |
| OLLAMA_URL="${OLLAMA_URL:-https://github.com/ollama/ollama/releases/latest/download/ollama-linux-$ARCH}" | |
| WEBUI_URL="${WEBUI_URL:-https://example.com/openwebui-linux-$ARCH}" | |
| DIFFUSION_URL="${DIFFUSION_URL:-https://example.com/opendiffusion-linux-$ARCH}" | |
| TERM_WIDTH=$(tput cols 2>/dev/null || echo 80) | |
| spinner() { | |
| local msg="$1" | |
| local pid=$! | |
| local spin='|/-\\' | |
| local delay=0.1 | |
| local i=0 | |
| printf "\rπ %-${TERM_WIDTH}s" "$msg..." | |
| while kill -0 "$pid" 2>/dev/null; do | |
| printf "\rπ %-s %s" "$msg..." "${spin:i++%${#spin}:1}" | |
| sleep "$delay" | |
| done | |
| printf "\rβ %-s%*s\n" "$msg..." $((TERM_WIDTH-${#msg}-4)) " " | |
| } | |
| log() { printf "\rβ€ %-s\n" "$1"; } | |
| debug() { $DEBUG && printf "\rπ DEBUG: %s\n" "$1"; } | |
| fatal() { printf "\rβ ERROR: %s\n" "$1" >&2; exit 1; } | |
| usage() { | |
| cat <<EOF | |
| LLM Installer - Version $VERSION | |
| Usage: $0 [--help] [--version] [--debug] [--uninstall] | |
| Options: | |
| --help Show this help message | |
| --version Show script version | |
| --debug Enable verbose debug output | |
| --uninstall Remove installed binaries and services | |
| Environment Overrides: | |
| OLLAMA_URL Override URL for Ollama binary | |
| WEBUI_URL Override URL for OpenWebUI binary | |
| DIFFUSION_URL Override URL for OpenDiffusion binary | |
| EOF | |
| exit 0 | |
| } | |
| for arg in "$@"; do | |
| case "$arg" in | |
| --help) usage ;; | |
| --version) echo "$VERSION"; exit 0 ;; | |
| --debug) DEBUG=true ;; | |
| --uninstall) UNINSTALL=true ;; | |
| *) fatal "Unknown option: $arg" ;; | |
| esac | |
| done | |
| if command -v sudo >/dev/null && sudo -n true 2>/dev/null; then | |
| ROOT=true | |
| BIN_DIR="/usr/local/bin" | |
| SHARE_DIR="/usr/local/share/llm-suite" | |
| SYSTEMD_DIR="/etc/systemd/system" | |
| else | |
| ROOT=false | |
| BIN_DIR="${XDG_BIN_HOME:-$HOME/.local/bin}" | |
| SHARE_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/llm-suite" | |
| SYSTEMD_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user" | |
| fi | |
| mkdir -p "$BIN_DIR" "$SHARE_DIR" "$SYSTEMD_DIR" | |
| OLLAMA_BIN="$BIN_DIR/ollama" | |
| WEBUI_BIN="$BIN_DIR/openwebui" | |
| DIFFUSION_BIN="$BIN_DIR/open-diffusion" | |
| SERVICE_FILE="$SYSTEMD_DIR/openwebui.service" | |
| install_ollama() { | |
| log "Installing Ollama" | |
| curl -fsSL "$OLLAMA_URL" -o "$OLLAMA_BIN" & | |
| spinner "Downloading Ollama" | |
| chmod +x "$OLLAMA_BIN" | |
| } | |
| install_webui() { | |
| log "Installing OpenWebUI" | |
| curl -fsSL "$WEBUI_URL" -o "$WEBUI_BIN" & | |
| spinner "Downloading OpenWebUI" | |
| chmod +x "$WEBUI_BIN" | |
| } | |
| install_diffusion() { | |
| log "Installing OpenDiffusion" | |
| curl -fsSL "$DIFFUSION_URL" -o "$DIFFUSION_BIN" & | |
| spinner "Downloading OpenDiffusion" | |
| chmod +x "$DIFFUSION_BIN" | |
| } | |
| pull_models() { | |
| log "Pulling Ollama models" | |
| "$OLLAMA_BIN" pull codellama:latest >/dev/null 2>&1 & | |
| spinner "Downloading codellama" | |
| "$OLLAMA_BIN" pull llama3:latest >/dev/null 2>&1 & | |
| spinner "Downloading llama3" | |
| "$OLLAMA_BIN" pull neural-chat:latest >/dev/null 2>&1 & | |
| spinner "Downloading neural-chat" | |
| } | |
| create_services() { | |
| log "Setting up systemd service for OpenWebUI" | |
| cat <<EOF > "$SERVICE_FILE" | |
| [Unit] | |
| Description=OpenWebUI Service | |
| After=network.target | |
| [Service] | |
| ExecStart=$WEBUI_BIN | |
| Restart=always | |
| [Install] | |
| WantedBy=multi-user.target | |
| EOF | |
| if [ "$ROOT" = true ]; then | |
| systemctl daemon-reexec | |
| systemctl daemon-reload | |
| systemctl enable --now openwebui.service | |
| else | |
| systemctl --user daemon-reexec | |
| systemctl --user daemon-reload | |
| systemctl --user enable --now openwebui.service | |
| fi | |
| spinner "OpenWebUI service started" | |
| } | |
| uninstall_all() { | |
| log "Uninstalling LLM suite" | |
| if [ -f "$SERVICE_FILE" ]; then | |
| if [ "$ROOT" = true ]; then | |
| systemctl disable --now openwebui.service || true | |
| else | |
| systemctl --user disable --now openwebui.service || true | |
| fi | |
| rm -f "$SERVICE_FILE" | |
| spinner "Removed systemd service" | |
| fi | |
| rm -f "$OLLAMA_BIN" "$WEBUI_BIN" "$DIFFUSION_BIN" | |
| rm -rf "$SHARE_DIR" | |
| spinner "Removed binaries and data" | |
| log "π§Ό Uninstall complete." | |
| exit 0 | |
| } | |
| # Execution | |
| if [ "$UNINSTALL" = true ]; then | |
| uninstall_all | |
| else | |
| install_ollama | |
| install_webui | |
| install_diffusion | |
| pull_models | |
| create_services | |
| log "π LLM suite installed successfully." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment