#!/bin/bash # Check everything we can before changing anything, so problems show up in the first minute, not the last. . "$(dirname "$0")/lib.sh" problems=0 need() { have "$1" || { warn "missing command: $1 ($2)"; problems=$((problems+1)); }; } say "operating system" [ -f /etc/os-release ] && . /etc/os-release && say " ${PRETTY_NAME:-unknown} on $(uname -m)" if ! have systemctl || [ ! -d /run/systemd/system ]; then die "this installer needs systemd (it runs the agent and the runtimes as services). On a system without systemd, run the agent by hand: see docs/en/INSTALL.md (Linux without systemd)." fi need curl "$(pkg_hint curl)" need python3 "$(pkg_hint python3)" need tar "$(pkg_hint tar)" need sudo "$(pkg_hint sudo)" need sha256sum "coreutils" need getent "libc-bin" [ "$problems" = 0 ] || die "install the missing commands above and run again" say "agent user: $OWNER (uid $OWNER_UID)" if step_enabled agent; then if [ -z "${WXCH_TOKEN:-}" ] && [ ! -s /etc/wxch-agent.env ]; then die "no agent token. On the server run: wxch-server -config -add-agent and use the command it prints." fi fi say "network" curl -fsS -o /dev/null --max-time 15 "$BASE/get" || die "cannot reach $BASE/get" if step_enabled ollama; then curl -fsS -o /dev/null --max-time 15 -I https://ollama.com || warn "cannot reach ollama.com (Ollama install will fail)"; fi if step_enabled lmstudio; then curl -fsS -o /dev/null --max-time 15 -I https://lmstudio.ai || warn "cannot reach lmstudio.ai (LM Studio install will fail)"; fi if step_enabled vllm; then curl -fsS -o /dev/null --max-time 15 -I https://huggingface.co || warn "cannot reach huggingface.co (vLLM model download will fail)" curl -sS -o /dev/null --max-time 15 -I https://nvcr.io/v2/ || warn "cannot reach nvcr.io (vLLM image pull will fail)"; fi # vLLM needs Docker and an NVIDIA GPU. Where they are missing it is skipped with a note instead of failing the # whole install (name it in WXCH_ONLY or set WXCH_VLLM=required to make it an error instead). rm -f /run/wxch-auto-skip-* if step_enabled vllm; then say "docker and GPU (vLLM)" why="" have nvidia-smi && nvidia-smi -L >/dev/null 2>&1 || why="no NVIDIA GPU found" [ -z "$why" ] && { have docker || why="docker is not installed"; } [ -z "$why" ] && { docker info >/dev/null 2>&1 || why="docker is installed but not running (systemctl start docker)"; } if [ -n "$why" ]; then if [ -n "${WXCH_ONLY:-}" ] || [ "${WXCH_VLLM:-}" = required ]; then die "vLLM cannot be installed: $why"; fi warn "skipping vLLM: $why. Ollama and LM Studio are still installed." touch /run/wxch-auto-skip-vllm else have nvidia-ctk || warn "nvidia-ctk not found: GPU containers may not start (install the NVIDIA container toolkit)" fi fi have nvidia-smi && say " GPU: $(nvidia-smi --query-gpu=name --format=csv,noheader | head -1)" || warn "nvidia-smi not found: models would run on the CPU" if step_enabled lmstudio; then ldconfig -p 2>/dev/null | grep -q libatomic || { say "installing $(pkg_name libatomic) (needed by LM Studio)"; pkg_install "$(pkg_name libatomic)" || warn "could not install $(pkg_name libatomic)"; } fi # disk space: Docker image ~11 GB, starter models ~3 GB, runtimes ~3 GB target="$MODELS_DIR"; [ -d "$target" ] || target=/ free_gb=$(df -BG --output=avail "$target" 2>/dev/null | tail -1 | tr -dc '0-9') root_gb=$(df -BG --output=avail / 2>/dev/null | tail -1 | tr -dc '0-9') say "free space: ${free_gb:-?} GB for models, ${root_gb:-?} GB on the system disk" [ "${root_gb:-100}" -ge 20 ] || warn "less than 20 GB free on the system disk (the vLLM image needs about 11 GB)" say "preflight ok"