From 1161c0b352728e040ed0adb58c94db5fd394101d Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 3 Mar 2026 23:31:02 -0500 Subject: [PATCH 001/101] feat: add LocalAGI installation and configuration scripts --- ct/localagi.sh | 136 +++++++++++++++++++++++++++++ frontend/public/json/localagi.json | 45 ++++++++++ install/localagi-install.sh | 104 ++++++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 ct/localagi.sh create mode 100644 frontend/public/json/localagi.json create mode 100644 install/localagi-install.sh diff --git a/ct/localagi.sh b/ct/localagi.sh new file mode 100644 index 000000000..d7762184f --- /dev/null +++ b/ct/localagi.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash +COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-${COMMUNITY_SCRIPT_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main}}" +source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func") + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: GitHub Copilot +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/mudler/LocalAGI + +APP="LocalAGI" +var_tags="${var_tags:-ai;agents}" +var_cpu="${var_cpu:-4}" +var_ram="${var_ram:-8192}" +var_disk="${var_disk:-30}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_unprivileged="${var_unprivileged:-1}" +var_gpu="${var_gpu:-yes}" + +header_info "$APP" +variables +color +catch_errors + +resolve_backend() { + local requested="${var_localagi_backend:-${var_torch_backend:-auto}}" + local backend="cpu" + + case "$requested" in + cpu | cu128 | rocm7.2) + backend="$requested" + ;; + *) + if [[ "${var_gpu:-no}" == "yes" ]]; then + if [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]]; then + backend="cu128" + elif [[ -e /dev/kfd ]]; then + backend="rocm7.2" + fi + fi + ;; + esac + + echo "$backend" +} + +compose_file_for_backend() { + case "$1" in + cu128) + echo "docker-compose.nvidia.yaml" + ;; + rocm7.2) + echo "docker-compose.amd.yaml" + ;; + *) + echo "docker-compose.yaml" + ;; + esac +} + +run_compose() { + if docker compose version >/dev/null 2>&1; then + docker compose "$@" + elif command -v docker-compose >/dev/null 2>&1; then + docker-compose "$@" + else + msg_error "Docker Compose is not available" + return 1 + fi +} + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /opt/localagi/docker-compose.yaml ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + local update_performed="no" + if check_for_gh_release "localagi" "mudler/LocalAGI"; then + update_performed="yes" + + msg_info "Stopping LocalAGI Stack" + cd /opt/localagi || exit + CURRENT_COMPOSE_FILE="$(cat /opt/localagi/.compose_file 2>/dev/null || echo docker-compose.yaml)" + run_compose -f "$CURRENT_COMPOSE_FILE" down || true + msg_ok "Stopped LocalAGI Stack" + + msg_info "Updating LocalAGI" + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" + msg_ok "Updated LocalAGI" + fi + + BACKEND="$(resolve_backend)" + COMPOSE_FILE="$(compose_file_for_backend "$BACKEND")" + + if [[ ! -f "/opt/localagi/${COMPOSE_FILE}" ]]; then + msg_warn "Compose profile ${COMPOSE_FILE} not found, falling back to CPU profile" + BACKEND="cpu" + COMPOSE_FILE="docker-compose.yaml" + fi + + echo "$BACKEND" >/opt/localagi/.backend + echo "$COMPOSE_FILE" >/opt/localagi/.compose_file + + msg_info "Deploying LocalAGI (${BACKEND})" + cd /opt/localagi || exit + if ! run_compose -f "$COMPOSE_FILE" pull; then + msg_error "Failed to pull LocalAGI images" + exit + fi + if ! run_compose -f "$COMPOSE_FILE" up -d; then + msg_error "Failed to start LocalAGI stack" + exit + fi + msg_ok "Deployed LocalAGI (${BACKEND})" + + if [[ "$update_performed" == "yes" ]]; then + msg_ok "Updated successfully!" + else + msg_ok "No update required. Reapplied compose profile successfully." + fi + exit +} + +start +build_container +description + +msg_ok "Completed successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}" diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json new file mode 100644 index 000000000..b9e4d3695 --- /dev/null +++ b/frontend/public/json/localagi.json @@ -0,0 +1,45 @@ +{ + "name": "LocalAGI", + "slug": "localagi", + "categories": [ + 20, + 3 + ], + "date_created": "2026-03-03", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 8080, + "documentation": "https://github.com/mudler/LocalAGI#installation-options", + "website": "https://github.com/mudler/LocalAGI", + "logo": "https://github.com/mudler/LocalAGI/raw/main/webui/react-ui/public/logo_1.png", + "config_path": "/opt/localagi/docker-compose.yaml", + "description": "LocalAGI is a self-hostable AI agent platform with a web UI, OpenAI-compatible APIs, and local-first model orchestration.", + "install_methods": [ + { + "type": "default", + "script": "ct/localagi.sh", + "resources": { + "cpu": 4, + "ram": 8192, + "hdd": 30, + "os": "Debian", + "version": "13" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "GPU passthrough can be enabled during CT creation. Backend auto-selects (`cu128` for NVIDIA, `rocm7.2` for AMD) and falls back to CPU.", + "type": "info" + }, + { + "text": "Set `var_localagi_backend=cpu|cu128|rocm7.2` (or `var_torch_backend`) to force a specific backend profile.", + "type": "info" + } + ] +} diff --git a/install/localagi-install.sh b/install/localagi-install.sh new file mode 100644 index 000000000..2b3a08332 --- /dev/null +++ b/install/localagi-install.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: GitHub Copilot +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/mudler/LocalAGI + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +resolve_backend() { + local requested="${var_localagi_backend:-${var_torch_backend:-auto}}" + local backend="cpu" + + case "$requested" in + cpu | cu128 | rocm7.2) + backend="$requested" + ;; + *) + if [[ "${var_gpu:-no}" == "yes" ]]; then + if [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]]; then + backend="cu128" + elif [[ -e /dev/kfd ]]; then + backend="rocm7.2" + fi + fi + ;; + esac + + echo "$backend" +} + +compose_file_for_backend() { + case "$1" in + cu128) + echo "docker-compose.nvidia.yaml" + ;; + rocm7.2) + echo "docker-compose.amd.yaml" + ;; + *) + echo "docker-compose.yaml" + ;; + esac +} + +run_compose() { + if docker compose version >/dev/null 2>&1; then + docker compose "$@" + elif command -v docker-compose >/dev/null 2>&1; then + docker-compose "$@" + else + msg_error "Docker Compose is not available" + return 1 + fi +} + +msg_info "Installing Dependencies" +$STD apt install -y \ + curl \ + ca-certificates \ + git \ + jq +msg_ok "Installed Dependencies" + +msg_info "Installing Docker" +setup_docker +msg_ok "Installed Docker" + +msg_info "Installing LocalAGI" +CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" +msg_ok "Installed LocalAGI" + +BACKEND="$(resolve_backend)" +COMPOSE_FILE="$(compose_file_for_backend "$BACKEND")" +if [[ ! -f "/opt/localagi/${COMPOSE_FILE}" ]]; then + msg_warn "Compose profile ${COMPOSE_FILE} not found, falling back to CPU profile" + BACKEND="cpu" + COMPOSE_FILE="docker-compose.yaml" +fi + +echo "$BACKEND" >/opt/localagi/.backend +echo "$COMPOSE_FILE" >/opt/localagi/.compose_file + +msg_info "Starting LocalAGI (${BACKEND})" +cd /opt/localagi || exit +if ! run_compose -f "$COMPOSE_FILE" pull; then + msg_error "Failed to pull LocalAGI images" + exit 1 +fi +if ! run_compose -f "$COMPOSE_FILE" up -d; then + msg_error "Failed to start LocalAGI stack" + exit 1 +fi +msg_ok "Started LocalAGI (${BACKEND})" + +motd_ssh +customize +cleanup_lxc From f85543886f3bd83ac89de1d2fb908cbe09a56f34 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 3 Mar 2026 23:41:11 -0500 Subject: [PATCH 002/101] feat: add AMD device support and localagi header file --- ct/headers/localagi | 6 ++++++ misc/build.func | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 ct/headers/localagi diff --git a/ct/headers/localagi b/ct/headers/localagi new file mode 100644 index 000000000..b65f4068d --- /dev/null +++ b/ct/headers/localagi @@ -0,0 +1,6 @@ + __ __ ___ __________ + / / ____ ________ _/ / / | / ____/ _/ + / / / __ \/ ___/ __ `/ / / /| |/ / __ / / + / /___/ /_/ / /__/ /_/ / / / ___ / /_/ // / +/_____/\____/\___/\__,_/_/ /_/ |_\____/___/ + diff --git a/misc/build.func b/misc/build.func index 1b24c1f7c..2a85c3e67 100644 --- a/misc/build.func +++ b/misc/build.func @@ -4282,6 +4282,9 @@ $PCT_OPTIONS_STRING" done fi fi + if [[ -e /dev/kfd ]]; then + AMD_DEVICES+=("/dev/kfd") + fi fi # Check for NVIDIA GPU - look for NVIDIA vendor ID [10de] From d4f74b05b07126f272d6a8562c0996146476167f Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 3 Mar 2026 23:47:27 -0500 Subject: [PATCH 003/101] feat: enhance LocalAGI installation and update scripts with source build and systemd service integration --- ct/localagi.sh | 100 ++++++++++++++------------ frontend/public/json/localagi.json | 13 ++-- install/localagi-install.sh | 111 ++++++++++++++++++----------- 3 files changed, 132 insertions(+), 92 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index d7762184f..c84ed92f3 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -44,29 +44,25 @@ resolve_backend() { echo "$backend" } -compose_file_for_backend() { - case "$1" in - cu128) - echo "docker-compose.nvidia.yaml" - ;; - rocm7.2) - echo "docker-compose.amd.yaml" - ;; - *) - echo "docker-compose.yaml" - ;; - esac +set_env_var() { + local env_file="$1" + local key="$2" + local value="$3" + if grep -q "^${key}=" "$env_file"; then + sed -i "s|^${key}=.*|${key}=${value}|" "$env_file" + else + echo "${key}=${value}" >>"$env_file" + fi } -run_compose() { - if docker compose version >/dev/null 2>&1; then - docker compose "$@" - elif command -v docker-compose >/dev/null 2>&1; then - docker-compose "$@" - else - msg_error "Docker Compose is not available" - return 1 - fi +build_localagi_source() { + msg_info "Building LocalAGI from source" + cd /opt/localagi/webui/react-ui || return 1 + $STD bun install || return 1 + $STD bun run build || return 1 + cd /opt/localagi || return 1 + $STD go build -o /usr/local/bin/localagi || return 1 + msg_ok "Built LocalAGI from source" } function update_script() { @@ -74,7 +70,7 @@ function update_script() { check_container_storage check_container_resources - if [[ ! -f /opt/localagi/docker-compose.yaml ]]; then + if [[ ! -d /opt/localagi || ! -f /etc/systemd/system/localagi.service ]]; then msg_error "No ${APP} Installation Found!" exit fi @@ -83,45 +79,57 @@ function update_script() { if check_for_gh_release "localagi" "mudler/LocalAGI"; then update_performed="yes" - msg_info "Stopping LocalAGI Stack" - cd /opt/localagi || exit - CURRENT_COMPOSE_FILE="$(cat /opt/localagi/.compose_file 2>/dev/null || echo docker-compose.yaml)" - run_compose -f "$CURRENT_COMPOSE_FILE" down || true - msg_ok "Stopped LocalAGI Stack" + msg_info "Stopping LocalAGI Service" + systemctl stop localagi + msg_ok "Stopped LocalAGI Service" + + msg_info "Backing up Environment" + cp /opt/localagi/.env /tmp/localagi.env.backup 2>/dev/null || true + msg_ok "Backed up Environment" msg_info "Updating LocalAGI" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" msg_ok "Updated LocalAGI" + + if [[ -f /tmp/localagi.env.backup ]]; then + msg_info "Restoring Environment" + cp /tmp/localagi.env.backup /opt/localagi/.env + rm -f /tmp/localagi.env.backup + msg_ok "Restored Environment" + fi fi BACKEND="$(resolve_backend)" - COMPOSE_FILE="$(compose_file_for_backend "$BACKEND")" - - if [[ ! -f "/opt/localagi/${COMPOSE_FILE}" ]]; then - msg_warn "Compose profile ${COMPOSE_FILE} not found, falling back to CPU profile" - BACKEND="cpu" - COMPOSE_FILE="docker-compose.yaml" - fi - - echo "$BACKEND" >/opt/localagi/.backend - echo "$COMPOSE_FILE" >/opt/localagi/.compose_file - - msg_info "Deploying LocalAGI (${BACKEND})" - cd /opt/localagi || exit - if ! run_compose -f "$COMPOSE_FILE" pull; then - msg_error "Failed to pull LocalAGI images" + if [[ ! -f /opt/localagi/.env ]]; then + msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." exit fi - if ! run_compose -f "$COMPOSE_FILE" up -d; then - msg_error "Failed to start LocalAGI stack" + + NODE_VERSION="24" setup_nodejs + GO_VERSION="latest" setup_go + if ! command -v bun >/dev/null 2>&1; then + msg_info "Installing Bun" + $STD npm install -g bun + msg_ok "Installed Bun" + fi + + set_env_var /opt/localagi/.env "LOCALAGI_GPU_BACKEND" "$BACKEND" + if ! build_localagi_source; then + msg_error "Failed to build LocalAGI from source" exit fi - msg_ok "Deployed LocalAGI (${BACKEND})" + + msg_info "Starting LocalAGI Service" + if ! systemctl restart localagi; then + msg_error "Failed to start LocalAGI service" + exit + fi + msg_ok "Started LocalAGI (${BACKEND})" if [[ "$update_performed" == "yes" ]]; then msg_ok "Updated successfully!" else - msg_ok "No update required. Reapplied compose profile successfully." + msg_ok "No update required. Rebuilt source and restarted service." fi exit } diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index b9e4d3695..b1f7ff164 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -2,8 +2,7 @@ "name": "LocalAGI", "slug": "localagi", "categories": [ - 20, - 3 + 20 ], "date_created": "2026-03-03", "type": "ct", @@ -13,7 +12,7 @@ "documentation": "https://github.com/mudler/LocalAGI#installation-options", "website": "https://github.com/mudler/LocalAGI", "logo": "https://github.com/mudler/LocalAGI/raw/main/webui/react-ui/public/logo_1.png", - "config_path": "/opt/localagi/docker-compose.yaml", + "config_path": "/opt/localagi/.env", "description": "LocalAGI is a self-hostable AI agent platform with a web UI, OpenAI-compatible APIs, and local-first model orchestration.", "install_methods": [ { @@ -34,11 +33,15 @@ }, "notes": [ { - "text": "GPU passthrough can be enabled during CT creation. Backend auto-selects (`cu128` for NVIDIA, `rocm7.2` for AMD) and falls back to CPU.", + "text": "This script builds LocalAGI from source (Go + Bun) and runs it as a systemd service.", "type": "info" }, { - "text": "Set `var_localagi_backend=cpu|cu128|rocm7.2` (or `var_torch_backend`) to force a specific backend profile.", + "text": "GPU passthrough can be enabled during CT creation. `var_localagi_backend=cpu|cu128|rocm7.2` is recorded as `LOCALAGI_GPU_BACKEND` for your runtime setup.", + "type": "info" + }, + { + "text": "By default, LocalAGI is configured to call an external OpenAI-compatible backend at `http://127.0.0.1:8081` via `LOCALAGI_LLM_API_URL`.", "type": "info" } ] diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 2b3a08332..664ff4982 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -6,12 +6,14 @@ # Source: https://github.com/mudler/LocalAGI source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +APP="LocalAGI" color verb_ip6 catch_errors setting_up_container network_check update_os +header_info "$APP" resolve_backend() { local requested="${var_localagi_backend:-${var_torch_backend:-auto}}" @@ -35,29 +37,25 @@ resolve_backend() { echo "$backend" } -compose_file_for_backend() { - case "$1" in - cu128) - echo "docker-compose.nvidia.yaml" - ;; - rocm7.2) - echo "docker-compose.amd.yaml" - ;; - *) - echo "docker-compose.yaml" - ;; - esac +set_env_var() { + local env_file="$1" + local key="$2" + local value="$3" + if grep -q "^${key}=" "$env_file"; then + sed -i "s|^${key}=.*|${key}=${value}|" "$env_file" + else + echo "${key}=${value}" >>"$env_file" + fi } -run_compose() { - if docker compose version >/dev/null 2>&1; then - docker compose "$@" - elif command -v docker-compose >/dev/null 2>&1; then - docker-compose "$@" - else - msg_error "Docker Compose is not available" - return 1 - fi +build_localagi_source() { + msg_info "Building LocalAGI from source" + cd /opt/localagi/webui/react-ui || return 1 + $STD bun install || return 1 + $STD bun run build || return 1 + cd /opt/localagi || return 1 + $STD go build -o /usr/local/bin/localagi || return 1 + msg_ok "Built LocalAGI from source" } msg_info "Installing Dependencies" @@ -65,36 +63,67 @@ $STD apt install -y \ curl \ ca-certificates \ git \ - jq + jq \ + build-essential msg_ok "Installed Dependencies" -msg_info "Installing Docker" -setup_docker -msg_ok "Installed Docker" +NODE_VERSION="24" setup_nodejs +GO_VERSION="latest" setup_go -msg_info "Installing LocalAGI" +msg_info "Installing Bun" +if ! command -v bun >/dev/null 2>&1; then + $STD npm install -g bun +fi +msg_ok "Installed Bun" + +msg_info "Fetching LocalAGI Source" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" -msg_ok "Installed LocalAGI" +msg_ok "Fetched LocalAGI Source" BACKEND="$(resolve_backend)" -COMPOSE_FILE="$(compose_file_for_backend "$BACKEND")" -if [[ ! -f "/opt/localagi/${COMPOSE_FILE}" ]]; then - msg_warn "Compose profile ${COMPOSE_FILE} not found, falling back to CPU profile" - BACKEND="cpu" - COMPOSE_FILE="docker-compose.yaml" -fi +mkdir -p /opt/localagi/pool -echo "$BACKEND" >/opt/localagi/.backend -echo "$COMPOSE_FILE" >/opt/localagi/.compose_file +msg_info "Configuring LocalAGI" +cat </opt/localagi/.env +LOCALAGI_MODEL=gemma-3-4b-it-qat +LOCALAGI_MULTIMODAL_MODEL=moondream2-20250414 +LOCALAGI_IMAGE_MODEL=sd-1.5-ggml +LOCALAGI_LLM_API_URL=http://127.0.0.1:8081 +LOCALAGI_STATE_DIR=/opt/localagi/pool +LOCALAGI_TIMEOUT=5m +LOCALAGI_ENABLE_CONVERSATIONS_LOGGING=false +LOCALAGI_GPU_BACKEND=${BACKEND} +EOF +msg_ok "Configured LocalAGI" -msg_info "Starting LocalAGI (${BACKEND})" -cd /opt/localagi || exit -if ! run_compose -f "$COMPOSE_FILE" pull; then - msg_error "Failed to pull LocalAGI images" +if ! build_localagi_source; then + msg_error "Failed to build LocalAGI from source" exit 1 fi -if ! run_compose -f "$COMPOSE_FILE" up -d; then - msg_error "Failed to start LocalAGI stack" + +msg_info "Creating Service" +cat </etc/systemd/system/localagi.service +[Unit] +Description=LocalAGI Service +After=network.target + +[Service] +Type=simple +WorkingDirectory=/opt/localagi +EnvironmentFile=/opt/localagi/.env +ExecStart=/usr/local/bin/localagi +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl daemon-reload +systemctl enable -q --now localagi +msg_ok "Created Service" + +if ! systemctl is-active -q localagi; then + msg_error "Failed to start LocalAGI service" exit 1 fi msg_ok "Started LocalAGI (${BACKEND})" From b603aa06703141b088d1be8121337eef27458319 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 3 Mar 2026 23:49:57 -0500 Subject: [PATCH 004/101] feat: add ROCm runtime installation for Debian in localagi scripts --- ct/localagi.sh | 44 +++++++++++++++++++++++++++++ install/localagi-install.sh | 56 +++++++++++++++++++++++++++++-------- 2 files changed, 89 insertions(+), 11 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index c84ed92f3..75345b76f 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -65,6 +65,46 @@ build_localagi_source() { msg_ok "Built LocalAGI from source" } +install_rocm_runtime_debian() { + if [[ -f /etc/os-release ]]; then + . /etc/os-release + fi + + local rocm_suite="" + case "${VERSION_ID:-}" in + 13*) rocm_suite="noble" ;; + 12*) rocm_suite="jammy" ;; + *) + msg_warn "Unsupported Debian version for automatic ROCm repo setup" + return 1 + ;; + esac + + msg_info "Configuring ROCm apt repositories (${rocm_suite})" + mkdir -p /etc/apt/keyrings + if ! curl -fsSL https://repo.radeon.com/rocm/rocm.gpg.key | gpg --dearmor -o /etc/apt/keyrings/rocm.gpg; then + msg_warn "Failed to add ROCm apt signing key" + return 1 + fi + + cat </etc/apt/sources.list.d/rocm.list +deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/7.2 ${rocm_suite} main +deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/graphics/7.2/ubuntu ${rocm_suite} main +EOF + + cat </etc/apt/preferences.d/rocm-pin-600 +Package: * +Pin: release o=repo.radeon.com +Pin-Priority: 600 +EOF + + msg_info "Installing ROCm runtime packages" + $STD apt update || return 1 + $STD apt install -y rocm || return 1 + ldconfig || true + msg_ok "Installed ROCm runtime packages" +} + function update_script() { header_info check_container_storage @@ -105,6 +145,10 @@ function update_script() { exit fi + if [[ "${BACKEND}" == "rocm7.2" ]]; then + install_rocm_runtime_debian || msg_warn "ROCm runtime package installation failed" + fi + NODE_VERSION="24" setup_nodejs GO_VERSION="latest" setup_go if ! command -v bun >/dev/null 2>&1; then diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 664ff4982..33b4c8884 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -37,17 +37,6 @@ resolve_backend() { echo "$backend" } -set_env_var() { - local env_file="$1" - local key="$2" - local value="$3" - if grep -q "^${key}=" "$env_file"; then - sed -i "s|^${key}=.*|${key}=${value}|" "$env_file" - else - echo "${key}=${value}" >>"$env_file" - fi -} - build_localagi_source() { msg_info "Building LocalAGI from source" cd /opt/localagi/webui/react-ui || return 1 @@ -58,12 +47,53 @@ build_localagi_source() { msg_ok "Built LocalAGI from source" } +install_rocm_runtime_debian() { + if [[ -f /etc/os-release ]]; then + . /etc/os-release + fi + + local rocm_suite="" + case "${VERSION_ID:-}" in + 13*) rocm_suite="noble" ;; + 12*) rocm_suite="jammy" ;; + *) + msg_warn "Unsupported Debian version for automatic ROCm repo setup" + return 1 + ;; + esac + + msg_info "Configuring ROCm apt repositories (${rocm_suite})" + mkdir -p /etc/apt/keyrings + if ! curl -fsSL https://repo.radeon.com/rocm/rocm.gpg.key | gpg --dearmor -o /etc/apt/keyrings/rocm.gpg; then + msg_warn "Failed to add ROCm apt signing key" + return 1 + fi + + cat </etc/apt/sources.list.d/rocm.list +deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/7.2 ${rocm_suite} main +deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/graphics/7.2/ubuntu ${rocm_suite} main +EOF + + cat </etc/apt/preferences.d/rocm-pin-600 +Package: * +Pin: release o=repo.radeon.com +Pin-Priority: 600 +EOF + + msg_info "Installing ROCm runtime packages" + $STD apt update || return 1 + $STD apt install -y rocm || return 1 + ldconfig || true + msg_ok "Installed ROCm runtime packages" +} + msg_info "Installing Dependencies" $STD apt install -y \ curl \ ca-certificates \ git \ jq \ + gnupg \ build-essential msg_ok "Installed Dependencies" @@ -83,6 +113,10 @@ msg_ok "Fetched LocalAGI Source" BACKEND="$(resolve_backend)" mkdir -p /opt/localagi/pool +if [[ "${BACKEND}" == "rocm7.2" ]]; then + install_rocm_runtime_debian || msg_warn "ROCm runtime package installation failed" +fi + msg_info "Configuring LocalAGI" cat </opt/localagi/.env LOCALAGI_MODEL=gemma-3-4b-it-qat From 39009f50f722805a4faa0308fe3c4a1d0f9128ce Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 3 Mar 2026 23:53:10 -0500 Subject: [PATCH 005/101] feat: implement resilient APT package installation and retry logic --- install/localagi-install.sh | 43 ++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 33b4c8884..a1c3d07c8 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -47,6 +47,43 @@ build_localagi_source() { msg_ok "Built LocalAGI from source" } +retry_cmd() { + local max_attempts="$1" + local base_delay="$2" + shift 2 + local attempt=1 + while [[ $attempt -le $max_attempts ]]; do + if "$@"; then + return 0 + fi + if [[ $attempt -lt $max_attempts ]]; then + msg_warn "Command failed (attempt ${attempt}/${max_attempts}): $*" + sleep $((base_delay * attempt)) + fi + attempt=$((attempt + 1)) + done + return 1 +} + +apt_recover_indexes() { + rm -rf /var/lib/apt/lists/partial/* /var/lib/apt/lists/* 2>/dev/null || true + $STD apt clean + $STD apt update +} + +install_apt_packages_resilient() { + if retry_cmd 3 5 env STD="$STD" bash -lc '$STD apt install -y "$@"' _ "$@"; then + return 0 + fi + + msg_warn "APT install failed; attempting index recovery and retry" + if ! retry_cmd 2 5 apt_recover_indexes; then + return 1 + fi + + retry_cmd 2 5 env STD="$STD" bash -lc '$STD apt install -y --fix-missing "$@"' _ "$@" +} + install_rocm_runtime_debian() { if [[ -f /etc/os-release ]]; then . /etc/os-release @@ -81,14 +118,14 @@ Pin-Priority: 600 EOF msg_info "Installing ROCm runtime packages" - $STD apt update || return 1 - $STD apt install -y rocm || return 1 + retry_cmd 3 5 env STD="$STD" bash -lc '$STD apt update' || return 1 + install_apt_packages_resilient rocm || return 1 ldconfig || true msg_ok "Installed ROCm runtime packages" } msg_info "Installing Dependencies" -$STD apt install -y \ +install_apt_packages_resilient \ curl \ ca-certificates \ git \ From c2dba1e0529267a557156560e627f1c80ba6b2fd Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 3 Mar 2026 23:53:28 -0500 Subject: [PATCH 006/101] feat: refactor APT package installation functions for improved readability and maintainability --- install/localagi-install.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index a1c3d07c8..f44513fde 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -71,8 +71,20 @@ apt_recover_indexes() { $STD apt update } +apt_update_cmd() { + $STD apt update +} + +apt_install_cmd() { + $STD apt install -y "$@" +} + +apt_install_fix_missing_cmd() { + $STD apt install -y --fix-missing "$@" +} + install_apt_packages_resilient() { - if retry_cmd 3 5 env STD="$STD" bash -lc '$STD apt install -y "$@"' _ "$@"; then + if retry_cmd 3 5 apt_install_cmd "$@"; then return 0 fi @@ -81,7 +93,7 @@ install_apt_packages_resilient() { return 1 fi - retry_cmd 2 5 env STD="$STD" bash -lc '$STD apt install -y --fix-missing "$@"' _ "$@" + retry_cmd 2 5 apt_install_fix_missing_cmd "$@" } install_rocm_runtime_debian() { @@ -118,7 +130,7 @@ Pin-Priority: 600 EOF msg_info "Installing ROCm runtime packages" - retry_cmd 3 5 env STD="$STD" bash -lc '$STD apt update' || return 1 + retry_cmd 3 5 apt_update_cmd || return 1 install_apt_packages_resilient rocm || return 1 ldconfig || true msg_ok "Installed ROCm runtime packages" From 7e897f4e93d3af0145ec53600d808b0791774b10 Mon Sep 17 00:00:00 2001 From: John Doe Date: Tue, 3 Mar 2026 23:57:14 -0500 Subject: [PATCH 007/101] feat: enhance LocalAGI installation scripts with backend resolution and ROCm runtime support --- ct/localagi.sh | 30 ++++++++++++++++++++++- install/localagi-install.sh | 47 +++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 75345b76f..c2eb9938d 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -22,6 +22,13 @@ variables color catch_errors +# Decide which runtime backend label to use for LocalAGI during updates. +# Priority: +# 1) Explicit user choice (`var_localagi_backend` or `var_torch_backend`) +# 2) Auto-detection when GPU passthrough is enabled: +# - NVIDIA device nodes => `cu128` +# - AMD KFD node => `rocm7.2` +# 3) Fallback => `cpu` resolve_backend() { local requested="${var_localagi_backend:-${var_torch_backend:-auto}}" local backend="cpu" @@ -44,6 +51,8 @@ resolve_backend() { echo "$backend" } +# Update or append a key=value pair inside LocalAGI environment file. +# Used to keep backend and runtime flags in sync across updates. set_env_var() { local env_file="$1" local key="$2" @@ -55,6 +64,9 @@ set_env_var() { fi } +# Build LocalAGI from source using upstream workflow: +# - Build frontend in `webui/react-ui` with Bun +# - Build backend binary with Go to `/usr/local/bin/localagi` build_localagi_source() { msg_info "Building LocalAGI from source" cd /opt/localagi/webui/react-ui || return 1 @@ -65,6 +77,13 @@ build_localagi_source() { msg_ok "Built LocalAGI from source" } +# Install ROCm runtime via AMD Debian package-manager method. +# Steps: +# - Determine supported suite mapping for current Debian version +# - Install AMD signing key +# - Add ROCm and graphics repositories for 7.2 +# - Pin AMD repo origin +# - Install `rocm` meta-package install_rocm_runtime_debian() { if [[ -f /etc/os-release ]]; then . /etc/os-release @@ -106,19 +125,23 @@ EOF } function update_script() { + # Standard update prechecks and environment summary. header_info check_container_storage check_container_resources + # Ensure LocalAGI source install and service exist before update flow. if [[ ! -d /opt/localagi || ! -f /etc/systemd/system/localagi.service ]]; then msg_error "No ${APP} Installation Found!" exit fi + # Pull latest release and refresh source tree if a new version is available. local update_performed="no" if check_for_gh_release "localagi" "mudler/LocalAGI"; then update_performed="yes" + # Stop service and preserve runtime env before replacing source tree. msg_info "Stopping LocalAGI Service" systemctl stop localagi msg_ok "Stopped LocalAGI Service" @@ -139,16 +162,19 @@ function update_script() { fi fi + # Re-evaluate backend each update in case hardware/override changed. BACKEND="$(resolve_backend)" if [[ ! -f /opt/localagi/.env ]]; then msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." exit fi + # Provision ROCm runtime only when AMD backend is selected. if [[ "${BACKEND}" == "rocm7.2" ]]; then install_rocm_runtime_debian || msg_warn "ROCm runtime package installation failed" fi + # Ensure source-build toolchain exists for update rebuild step. NODE_VERSION="24" setup_nodejs GO_VERSION="latest" setup_go if ! command -v bun >/dev/null 2>&1; then @@ -157,12 +183,14 @@ function update_script() { msg_ok "Installed Bun" fi + # Persist backend marker and rebuild the project from source. set_env_var /opt/localagi/.env "LOCALAGI_GPU_BACKEND" "$BACKEND" if ! build_localagi_source; then msg_error "Failed to build LocalAGI from source" exit fi + # Restart service with rebuilt binary and current env settings. msg_info "Starting LocalAGI Service" if ! systemctl restart localagi; then msg_error "Failed to start LocalAGI service" @@ -185,4 +213,4 @@ description msg_ok "Completed successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" diff --git a/install/localagi-install.sh b/install/localagi-install.sh index f44513fde..ed43a97b9 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -7,6 +7,10 @@ source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" APP="LocalAGI" + +# Load common UI/helpers and perform standard container bootstrap lifecycle. +# - `color`, `verb_ip6`, `catch_errors`: logging/error behavior +# - `setting_up_container`, `network_check`, `update_os`: baseline prep/update color verb_ip6 catch_errors @@ -15,6 +19,13 @@ network_check update_os header_info "$APP" +# Decide which runtime backend label to use for LocalAGI. +# Priority: +# 1) Explicit user choice (`var_localagi_backend` or `var_torch_backend`) +# 2) Auto-detection when GPU passthrough is enabled: +# - NVIDIA device nodes => `cu128` +# - AMD KFD node => `rocm7.2` +# 3) Fallback => `cpu` resolve_backend() { local requested="${var_localagi_backend:-${var_torch_backend:-auto}}" local backend="cpu" @@ -37,6 +48,9 @@ resolve_backend() { echo "$backend" } +# Build LocalAGI from source using upstream workflow: +# - Build frontend in `webui/react-ui` with Bun +# - Build backend binary with Go to `/usr/local/bin/localagi` build_localagi_source() { msg_info "Building LocalAGI from source" cd /opt/localagi/webui/react-ui || return 1 @@ -47,6 +61,8 @@ build_localagi_source() { msg_ok "Built LocalAGI from source" } +# Generic command retry helper with linear backoff. +# Usage: retry_cmd [args...] retry_cmd() { local max_attempts="$1" local base_delay="$2" @@ -65,12 +81,16 @@ retry_cmd() { return 1 } +# Recovery path for transient apt repository/index failures. +# Especially useful for Hash Sum mismatch and stale list states. apt_recover_indexes() { rm -rf /var/lib/apt/lists/partial/* /var/lib/apt/lists/* 2>/dev/null || true $STD apt clean $STD apt update } +# Small wrappers so retry helper executes apt commands in current shell context. +# This avoids subshell issues with helper wrappers like `$STD` (e.g. `silent`). apt_update_cmd() { $STD apt update } @@ -83,6 +103,10 @@ apt_install_fix_missing_cmd() { $STD apt install -y --fix-missing "$@" } +# Resilient package install flow: +# 1) Retry normal install +# 2) If still failing, clean apt state + refresh indexes +# 3) Retry with `--fix-missing` install_apt_packages_resilient() { if retry_cmd 3 5 apt_install_cmd "$@"; then return 0 @@ -96,6 +120,13 @@ install_apt_packages_resilient() { retry_cmd 2 5 apt_install_fix_missing_cmd "$@" } +# Install ROCm runtime via AMD Debian package-manager method. +# Steps: +# - Determine supported suite mapping for current Debian version +# - Install AMD signing key +# - Add ROCm and graphics repositories for 7.2 +# - Pin AMD repo origin +# - Install `rocm` meta-package install_rocm_runtime_debian() { if [[ -f /etc/os-release ]]; then . /etc/os-release @@ -136,6 +167,8 @@ EOF msg_ok "Installed ROCm runtime packages" } +# Install base tooling needed to fetch/build/run LocalAGI. +# `gnupg` is required for ROCm key import path. msg_info "Installing Dependencies" install_apt_packages_resilient \ curl \ @@ -146,26 +179,35 @@ install_apt_packages_resilient \ build-essential msg_ok "Installed Dependencies" +# Install language/runtime toolchains used by LocalAGI source build. +# - Node.js: frontend/Bun ecosystem compatibility +# - Go: backend binary build NODE_VERSION="24" setup_nodejs GO_VERSION="latest" setup_go +# Install Bun package manager (if not already present). msg_info "Installing Bun" if ! command -v bun >/dev/null 2>&1; then $STD npm install -g bun fi msg_ok "Installed Bun" +# Pull latest LocalAGI source snapshot from GitHub release tarball. msg_info "Fetching LocalAGI Source" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" msg_ok "Fetched LocalAGI Source" +# Resolve backend and prepare persistent state directory. BACKEND="$(resolve_backend)" mkdir -p /opt/localagi/pool +# Only attempt ROCm runtime provisioning when AMD backend is selected. if [[ "${BACKEND}" == "rocm7.2" ]]; then install_rocm_runtime_debian || msg_warn "ROCm runtime package installation failed" fi +# Generate runtime configuration file used by systemd service. +# Note: `LOCALAGI_LLM_API_URL` points to an OpenAI-compatible backend endpoint. msg_info "Configuring LocalAGI" cat </opt/localagi/.env LOCALAGI_MODEL=gemma-3-4b-it-qat @@ -179,11 +221,14 @@ LOCALAGI_GPU_BACKEND=${BACKEND} EOF msg_ok "Configured LocalAGI" +# Build source tree into executable binary. if ! build_localagi_source; then msg_error "Failed to build LocalAGI from source" exit 1 fi +# Create and start systemd unit for LocalAGI. +# The service reads `/opt/localagi/.env` at runtime. msg_info "Creating Service" cat </etc/systemd/system/localagi.service [Unit] @@ -205,12 +250,14 @@ systemctl daemon-reload systemctl enable -q --now localagi msg_ok "Created Service" +# Verify service health before exiting installer. if ! systemctl is-active -q localagi; then msg_error "Failed to start LocalAGI service" exit 1 fi msg_ok "Started LocalAGI (${BACKEND})" +# Standard post-install housekeeping from shared framework. motd_ssh customize cleanup_lxc From f9755d110281a55669b6dbcbcb8fb0d25a1feaa8 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:04:07 -0500 Subject: [PATCH 008/101] feat: add AMD GPU detection for ROCm backend in LocalAGI installation scripts --- ct/localagi.sh | 4 ++++ install/localagi-install.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index c2eb9938d..7d89a63ed 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -43,6 +43,10 @@ resolve_backend() { backend="cu128" elif [[ -e /dev/kfd ]]; then backend="rocm7.2" + elif lspci 2>/dev/null | grep -qiE 'AMD|Radeon'; then + backend="rocm7.2" + elif grep -qEi '0x1002|0x1022' /sys/class/drm/renderD*/device/vendor /sys/class/drm/card*/device/vendor 2>/dev/null; then + backend="rocm7.2" fi fi ;; diff --git a/install/localagi-install.sh b/install/localagi-install.sh index ed43a97b9..f48954df8 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -40,6 +40,10 @@ resolve_backend() { backend="cu128" elif [[ -e /dev/kfd ]]; then backend="rocm7.2" + elif lspci 2>/dev/null | grep -qiE 'AMD|Radeon'; then + backend="rocm7.2" + elif grep -qEi '0x1002|0x1022' /sys/class/drm/renderD*/device/vendor /sys/class/drm/card*/device/vendor 2>/dev/null; then + backend="rocm7.2" fi fi ;; From cf986a34a9e461ead935c712d05918a8deff0b7a Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:07:13 -0500 Subject: [PATCH 009/101] feat: add function to ensure /dev/kfd passthrough for LocalAGI in LXC containers --- ct/localagi.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index 7d89a63ed..780ff05bd 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -128,6 +128,39 @@ EOF msg_ok "Installed ROCm runtime packages" } +ensure_localagi_kfd_passthrough() { + if [[ "${var_gpu:-no}" != "yes" ]]; then + return 0 + fi + + if [[ ! -e /dev/kfd ]]; then + return 0 + fi + + local lxc_config="/etc/pve/lxc/${CTID}.conf" + if [[ ! -f "${lxc_config}" ]]; then + return 0 + fi + + if grep -qE '^dev[0-9]+: /dev/kfd(,|$)' "${lxc_config}"; then + return 0 + fi + + local dev_index=0 + while grep -q "^dev${dev_index}:" "${lxc_config}"; do + dev_index=$((dev_index + 1)) + done + + echo "dev${dev_index}: /dev/kfd,gid=44" >>"${lxc_config}" + msg_ok "Added LocalAGI /dev/kfd passthrough" + + if pct status "${CTID}" 2>/dev/null | grep -q running; then + msg_info "Restarting container to apply /dev/kfd passthrough" + pct reboot "${CTID}" >/dev/null 2>&1 || true + msg_ok "Container restart requested" + fi +} + function update_script() { # Standard update prechecks and environment summary. header_info @@ -212,6 +245,7 @@ function update_script() { start build_container +ensure_localagi_kfd_passthrough description msg_ok "Completed successfully!\n" From d3d1da15cc4c0f8e2427923935e213262c42b572 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:08:01 -0500 Subject: [PATCH 010/101] feat: remove AMD device detection for /dev/kfd from build functions --- misc/build.func | 3 --- 1 file changed, 3 deletions(-) diff --git a/misc/build.func b/misc/build.func index 2a85c3e67..1b24c1f7c 100644 --- a/misc/build.func +++ b/misc/build.func @@ -4282,9 +4282,6 @@ $PCT_OPTIONS_STRING" done fi fi - if [[ -e /dev/kfd ]]; then - AMD_DEVICES+=("/dev/kfd") - fi fi # Check for NVIDIA GPU - look for NVIDIA vendor ID [10de] From 565705e837b675042e07aded6e2695ea2452bc68 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:09:48 -0500 Subject: [PATCH 011/101] feat: enhance GPU backend detection in LocalAGI installation scripts --- ct/localagi.sh | 20 ++++++++++++++++---- install/localagi-install.sh | 22 ++++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 780ff05bd..0505cea7b 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -32,6 +32,16 @@ catch_errors resolve_backend() { local requested="${var_localagi_backend:-${var_torch_backend:-auto}}" local backend="cpu" + local gpu_type="${GPU_TYPE:-unknown}" + local has_nvidia="no" + local has_kfd="no" + local has_amd_pci="no" + local has_amd_vendor="no" + + [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]] && has_nvidia="yes" + [[ -e /dev/kfd ]] && has_kfd="yes" + lspci 2>/dev/null | grep -qiE 'AMD|Radeon' && has_amd_pci="yes" + grep -qEi '0x1002|0x1022' /sys/class/drm/renderD*/device/vendor /sys/class/drm/card*/device/vendor 2>/dev/null && has_amd_vendor="yes" case "$requested" in cpu | cu128 | rocm7.2) @@ -39,19 +49,21 @@ resolve_backend() { ;; *) if [[ "${var_gpu:-no}" == "yes" ]]; then - if [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]]; then + if [[ "${gpu_type}" == "NVIDIA" || "${has_nvidia}" == "yes" ]]; then backend="cu128" - elif [[ -e /dev/kfd ]]; then + elif [[ "${gpu_type}" == "AMD" || "${has_kfd}" == "yes" ]]; then backend="rocm7.2" - elif lspci 2>/dev/null | grep -qiE 'AMD|Radeon'; then + elif [[ "${has_amd_pci}" == "yes" ]]; then backend="rocm7.2" - elif grep -qEi '0x1002|0x1022' /sys/class/drm/renderD*/device/vendor /sys/class/drm/card*/device/vendor 2>/dev/null; then + elif [[ "${has_amd_vendor}" == "yes" ]]; then backend="rocm7.2" fi fi ;; esac + msg_info "Backend detection: requested=${requested}, var_gpu=${var_gpu:-no}, GPU_TYPE=${gpu_type}, nvidia=${has_nvidia}, kfd=${has_kfd}, amd_pci=${has_amd_pci}, amd_vendor=${has_amd_vendor}, selected=${backend}" + echo "$backend" } diff --git a/install/localagi-install.sh b/install/localagi-install.sh index f48954df8..ef9aba0b8 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -29,6 +29,16 @@ header_info "$APP" resolve_backend() { local requested="${var_localagi_backend:-${var_torch_backend:-auto}}" local backend="cpu" + local gpu_type="${GPU_TYPE:-unknown}" + local has_nvidia="no" + local has_kfd="no" + local has_amd_pci="no" + local has_amd_vendor="no" + + [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]] && has_nvidia="yes" + [[ -e /dev/kfd ]] && has_kfd="yes" + lspci 2>/dev/null | grep -qiE 'AMD|Radeon' && has_amd_pci="yes" + grep -qEi '0x1002|0x1022' /sys/class/drm/renderD*/device/vendor /sys/class/drm/card*/device/vendor 2>/dev/null && has_amd_vendor="yes" case "$requested" in cpu | cu128 | rocm7.2) @@ -36,19 +46,21 @@ resolve_backend() { ;; *) if [[ "${var_gpu:-no}" == "yes" ]]; then - if [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]]; then + if [[ "${gpu_type}" == "NVIDIA" || "${has_nvidia}" == "yes" ]]; then backend="cu128" - elif [[ -e /dev/kfd ]]; then + elif [[ "${gpu_type}" == "AMD" || "${has_kfd}" == "yes" ]]; then backend="rocm7.2" - elif lspci 2>/dev/null | grep -qiE 'AMD|Radeon'; then + elif [[ "${has_amd_pci}" == "yes" ]]; then backend="rocm7.2" - elif grep -qEi '0x1002|0x1022' /sys/class/drm/renderD*/device/vendor /sys/class/drm/card*/device/vendor 2>/dev/null; then + elif [[ "${has_amd_vendor}" == "yes" ]]; then backend="rocm7.2" fi fi ;; esac + msg_info "Backend detection: requested=${requested}, var_gpu=${var_gpu:-no}, GPU_TYPE=${gpu_type}, nvidia=${has_nvidia}, kfd=${has_kfd}, amd_pci=${has_amd_pci}, amd_vendor=${has_amd_vendor}, selected=${backend}" + echo "$backend" } @@ -208,6 +220,8 @@ mkdir -p /opt/localagi/pool # Only attempt ROCm runtime provisioning when AMD backend is selected. if [[ "${BACKEND}" == "rocm7.2" ]]; then install_rocm_runtime_debian || msg_warn "ROCm runtime package installation failed" +else + msg_warn "ROCm install skipped because selected backend is '${BACKEND}'" fi # Generate runtime configuration file used by systemd service. From 55de0ad144c9d8eb7ecf9b4fd366c99bf0df2775 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:14:13 -0500 Subject: [PATCH 012/101] feat: improve backend detection summary in LocalAGI installation scripts --- ct/localagi.sh | 9 +++++---- install/localagi-install.sh | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 0505cea7b..24bbf3e3b 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -62,9 +62,8 @@ resolve_backend() { ;; esac - msg_info "Backend detection: requested=${requested}, var_gpu=${var_gpu:-no}, GPU_TYPE=${gpu_type}, nvidia=${has_nvidia}, kfd=${has_kfd}, amd_pci=${has_amd_pci}, amd_vendor=${has_amd_vendor}, selected=${backend}" - - echo "$backend" + RESOLVED_BACKEND="$backend" + BACKEND_DETECTION_SUMMARY="requested=${requested}, var_gpu=${var_gpu:-no}, GPU_TYPE=${gpu_type}, nvidia=${has_nvidia}, kfd=${has_kfd}, amd_pci=${has_amd_pci}, amd_vendor=${has_amd_vendor}, selected=${backend}" } # Update or append a key=value pair inside LocalAGI environment file. @@ -212,7 +211,9 @@ function update_script() { fi # Re-evaluate backend each update in case hardware/override changed. - BACKEND="$(resolve_backend)" + resolve_backend + BACKEND="${RESOLVED_BACKEND:-cpu}" + msg_info "Backend detection: ${BACKEND_DETECTION_SUMMARY:-unavailable}" if [[ ! -f /opt/localagi/.env ]]; then msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." exit diff --git a/install/localagi-install.sh b/install/localagi-install.sh index ef9aba0b8..343d93063 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -59,9 +59,8 @@ resolve_backend() { ;; esac - msg_info "Backend detection: requested=${requested}, var_gpu=${var_gpu:-no}, GPU_TYPE=${gpu_type}, nvidia=${has_nvidia}, kfd=${has_kfd}, amd_pci=${has_amd_pci}, amd_vendor=${has_amd_vendor}, selected=${backend}" - - echo "$backend" + RESOLVED_BACKEND="$backend" + BACKEND_DETECTION_SUMMARY="requested=${requested}, var_gpu=${var_gpu:-no}, GPU_TYPE=${gpu_type}, nvidia=${has_nvidia}, kfd=${has_kfd}, amd_pci=${has_amd_pci}, amd_vendor=${has_amd_vendor}, selected=${backend}" } # Build LocalAGI from source using upstream workflow: @@ -214,7 +213,9 @@ CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarbal msg_ok "Fetched LocalAGI Source" # Resolve backend and prepare persistent state directory. -BACKEND="$(resolve_backend)" +resolve_backend +BACKEND="${RESOLVED_BACKEND:-cpu}" +msg_info "Backend detection: ${BACKEND_DETECTION_SUMMARY:-unavailable}" mkdir -p /opt/localagi/pool # Only attempt ROCm runtime provisioning when AMD backend is selected. From 63615ded07bb55843113931c2061566e1e3f8bce Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:18:51 -0500 Subject: [PATCH 013/101] feat: enhance ROCm installation process and backend resolution in LocalAGI scripts --- ct/localagi.sh | 8 +++++--- install/localagi-install.sh | 14 +++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 24bbf3e3b..6c1bd1a48 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -132,9 +132,9 @@ Pin: release o=repo.radeon.com Pin-Priority: 600 EOF - msg_info "Installing ROCm runtime packages" - $STD apt update || return 1 - $STD apt install -y rocm || return 1 + msg_info "Installing ROCm runtime packages (this may take several minutes)" + apt update || return 1 + apt install -y rocm || return 1 ldconfig || true msg_ok "Installed ROCm runtime packages" } @@ -211,9 +211,11 @@ function update_script() { fi # Re-evaluate backend each update in case hardware/override changed. + msg_info "Resolving LocalAGI backend" resolve_backend BACKEND="${RESOLVED_BACKEND:-cpu}" msg_info "Backend detection: ${BACKEND_DETECTION_SUMMARY:-unavailable}" + msg_ok "Resolved LocalAGI backend: ${BACKEND}" if [[ ! -f /opt/localagi/.env ]]; then msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." exit diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 343d93063..b8c5e4e1f 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -175,9 +175,15 @@ Pin: release o=repo.radeon.com Pin-Priority: 600 EOF - msg_info "Installing ROCm runtime packages" - retry_cmd 3 5 apt_update_cmd || return 1 - install_apt_packages_resilient rocm || return 1 + msg_info "Installing ROCm runtime packages (this may take several minutes)" + if ! retry_cmd 3 5 apt update; then + msg_warn "ROCm apt repository update failed" + return 1 + fi + if ! retry_cmd 3 10 apt install -y rocm; then + msg_warn "ROCm runtime package installation failed" + return 1 + fi ldconfig || true msg_ok "Installed ROCm runtime packages" } @@ -213,10 +219,12 @@ CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarbal msg_ok "Fetched LocalAGI Source" # Resolve backend and prepare persistent state directory. +msg_info "Resolving LocalAGI backend" resolve_backend BACKEND="${RESOLVED_BACKEND:-cpu}" msg_info "Backend detection: ${BACKEND_DETECTION_SUMMARY:-unavailable}" mkdir -p /opt/localagi/pool +msg_ok "Resolved LocalAGI backend: ${BACKEND}" # Only attempt ROCm runtime provisioning when AMD backend is selected. if [[ "${BACKEND}" == "rocm7.2" ]]; then From 2d81660dc58ecb802dd2f0d70f43fcd985843a5f Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:23:38 -0500 Subject: [PATCH 014/101] feat: refactor header content retrieval in LocalAGI installation script --- install/localagi-install.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index b8c5e4e1f..5fe4ec279 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -17,7 +17,13 @@ catch_errors setting_up_container network_check update_os -header_info "$APP" +header_content="" +if declare -f get_header >/dev/null 2>&1; then + header_content=$(get_header 2>/dev/null || true) +fi +if [[ -n "$header_content" ]]; then + echo "$header_content" +fi # Decide which runtime backend label to use for LocalAGI. # Priority: From 4cdfa494606fc2852e224193669a38a8795b588b Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:25:11 -0500 Subject: [PATCH 015/101] feat: add backend detection for LocalAGI installation based on host GPU --- ct/localagi.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 6c1bd1a48..da3edbd13 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -22,6 +22,47 @@ variables color catch_errors +# Determine a backend override on the Proxmox host before container install. +# This avoids false CPU fallback when /dev/kfd is added after installation. +prepare_localagi_backend_override() { + if [[ -n "${var_localagi_backend:-}" && "${var_localagi_backend}" != "auto" ]]; then + export var_localagi_backend + return 0 + fi + + if [[ "${var_gpu:-no}" != "yes" ]]; then + return 0 + fi + + local detected_gpu_type="${GPU_TYPE:-}" + + if [[ -z "${detected_gpu_type}" ]]; then + if [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]]; then + detected_gpu_type="NVIDIA" + elif [[ -e /dev/kfd ]]; then + detected_gpu_type="AMD" + elif lspci 2>/dev/null | grep -qiE 'AMD|Radeon'; then + detected_gpu_type="AMD" + fi + fi + + case "${detected_gpu_type}" in + NVIDIA) + var_localagi_backend="cu128" + ;; + AMD) + var_localagi_backend="rocm7.2" + ;; + *) + return 0 + ;; + esac + + export GPU_TYPE="${detected_gpu_type}" + export var_localagi_backend + msg_info "Preselected LocalAGI backend: ${var_localagi_backend} (host GPU=${detected_gpu_type})" +} + # Decide which runtime backend label to use for LocalAGI during updates. # Priority: # 1) Explicit user choice (`var_localagi_backend` or `var_torch_backend`) @@ -259,11 +300,29 @@ function update_script() { } start +prepare_localagi_backend_override build_container -ensure_localagi_kfd_passthrough description +ensure_localagi_kfd_passthrough msg_ok "Completed successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" + +if [[ -z "${IP:-}" ]]; then + IP=$(pct exec "$CTID" -- sh -c "hostname -I 2>/dev/null | tr ' ' '\n' | grep -E '^[0-9]+\.' | head -n1") +fi +if [[ -z "${IP:-}" ]]; then + IP=$(pct exec "$CTID" -- sh -c "hostname -I 2>/dev/null | tr ' ' '\n' | grep -E ':' | head -n1") +fi + +URL_HOST="${IP:-}" +if [[ -n "${URL_HOST}" && "${URL_HOST}" == *:* ]]; then + URL_HOST="[${URL_HOST}]" +fi +if [[ -z "${URL_HOST}" ]]; then + msg_warn "Unable to determine container IP automatically" + echo -e "${TAB}${GATEWAY}${BGN}http://:3000${CL}" +else + echo -e "${TAB}${GATEWAY}${BGN}http://${URL_HOST}:3000${CL}" +fi From 390f2ff178333d9736cbd5ba38452d69879597b0 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:29:38 -0500 Subject: [PATCH 016/101] feat: increase default disk size to 60GB in LocalAGI installation scripts --- ct/localagi.sh | 2 +- frontend/public/json/localagi.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index da3edbd13..8b230f4f1 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -11,7 +11,7 @@ APP="LocalAGI" var_tags="${var_tags:-ai;agents}" var_cpu="${var_cpu:-4}" var_ram="${var_ram:-8192}" -var_disk="${var_disk:-30}" +var_disk="${var_disk:-60}" var_os="${var_os:-debian}" var_version="${var_version:-13}" var_unprivileged="${var_unprivileged:-1}" diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index b1f7ff164..c865efe16 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -21,7 +21,7 @@ "resources": { "cpu": 4, "ram": 8192, - "hdd": 30, + "hdd": 60, "os": "Debian", "version": "13" } From 79b5cb70af25cea35adaa29605c5add9545cc018 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:31:29 -0500 Subject: [PATCH 017/101] feat: enhance LocalAGI /dev/kfd passthrough handling based on GPU type and backend --- ct/localagi.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index 8b230f4f1..f1c382371 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -181,20 +181,31 @@ EOF } ensure_localagi_kfd_passthrough() { + local backend_hint="${var_localagi_backend:-${var_torch_backend:-auto}}" + if [[ "${var_gpu:-no}" != "yes" ]]; then + msg_warn "Skipping LocalAGI /dev/kfd passthrough: GPU passthrough is disabled" + return 0 + fi + + if [[ "${backend_hint}" != "rocm7.2" && "${GPU_TYPE:-}" != "AMD" ]]; then + msg_info "Skipping LocalAGI /dev/kfd passthrough: backend/GPU is not AMD" return 0 fi if [[ ! -e /dev/kfd ]]; then + msg_warn "Skipping LocalAGI /dev/kfd passthrough: host /dev/kfd not found" return 0 fi local lxc_config="/etc/pve/lxc/${CTID}.conf" if [[ ! -f "${lxc_config}" ]]; then + msg_warn "Skipping LocalAGI /dev/kfd passthrough: missing ${lxc_config}" return 0 fi if grep -qE '^dev[0-9]+: /dev/kfd(,|$)' "${lxc_config}"; then + msg_ok "LocalAGI /dev/kfd passthrough already present" return 0 fi From 83847ad98f6f043f21212f5668216a4fc6924021 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:32:00 -0500 Subject: [PATCH 018/101] feat: update logo URL in LocalAGI configuration to use CDN --- frontend/public/json/localagi.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index c865efe16..4f0ad2ffe 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -11,7 +11,7 @@ "interface_port": 8080, "documentation": "https://github.com/mudler/LocalAGI#installation-options", "website": "https://github.com/mudler/LocalAGI", - "logo": "https://github.com/mudler/LocalAGI/raw/main/webui/react-ui/public/logo_1.png", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/localagi.webp", "config_path": "/opt/localagi/.env", "description": "LocalAGI is a self-hostable AI agent platform with a web UI, OpenAI-compatible APIs, and local-first model orchestration.", "install_methods": [ From d49a8d04cdc25d006c3e7de6e11767af4c4fc7c2 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:35:43 -0500 Subject: [PATCH 019/101] feat: update ROCm installation commands to use standardized functions --- ct/localagi.sh | 4 ++-- install/localagi-install.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index f1c382371..cea6b7701 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -174,8 +174,8 @@ Pin-Priority: 600 EOF msg_info "Installing ROCm runtime packages (this may take several minutes)" - apt update || return 1 - apt install -y rocm || return 1 + $STD apt update || return 1 + $STD apt install -y rocm || return 1 ldconfig || true msg_ok "Installed ROCm runtime packages" } diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 5fe4ec279..1946d0b48 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -182,11 +182,11 @@ Pin-Priority: 600 EOF msg_info "Installing ROCm runtime packages (this may take several minutes)" - if ! retry_cmd 3 5 apt update; then + if ! retry_cmd 3 5 apt_update_cmd; then msg_warn "ROCm apt repository update failed" return 1 fi - if ! retry_cmd 3 10 apt install -y rocm; then + if ! retry_cmd 3 10 apt_install_cmd rocm; then msg_warn "ROCm runtime package installation failed" return 1 fi From 7ec67de15cc6262f60e925bc2c05a907049c4465 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:42:39 -0500 Subject: [PATCH 020/101] feat: update LOCALAGI_LLM_API_URL to Ollama-compatible endpoint and enhance documentation --- ct/localagi.sh | 5 +++++ frontend/public/json/localagi.json | 6 +++++- install/localagi-install.sh | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index cea6b7701..58739b96c 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -273,6 +273,11 @@ function update_script() { exit fi + if grep -q '^LOCALAGI_LLM_API_URL=http://127.0.0.1:8081$' /opt/localagi/.env; then + set_env_var /opt/localagi/.env "LOCALAGI_LLM_API_URL" "http://127.0.0.1:11434/v1" + msg_warn "Migrated LOCALAGI_LLM_API_URL from 127.0.0.1:8081 to 127.0.0.1:11434/v1" + fi + # Provision ROCm runtime only when AMD backend is selected. if [[ "${BACKEND}" == "rocm7.2" ]]; then install_rocm_runtime_debian || msg_warn "ROCm runtime package installation failed" diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index 4f0ad2ffe..a3a247096 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -41,7 +41,11 @@ "type": "info" }, { - "text": "By default, LocalAGI is configured to call an external OpenAI-compatible backend at `http://127.0.0.1:8081` via `LOCALAGI_LLM_API_URL`.", + "text": "By default, LocalAGI is configured to call an OpenAI-compatible backend at `http://127.0.0.1:11434/v1` (Ollama-compatible) via `LOCALAGI_LLM_API_URL`.", + "type": "info" + }, + { + "text": "To use an external Ollama host, edit `/opt/localagi/.env` and set `LOCALAGI_LLM_API_URL=http://:11434/v1`, then restart LocalAGI with `systemctl restart localagi`.", "type": "info" } ] diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 1946d0b48..61082c252 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -241,12 +241,13 @@ fi # Generate runtime configuration file used by systemd service. # Note: `LOCALAGI_LLM_API_URL` points to an OpenAI-compatible backend endpoint. +# Defaulting to Ollama's OpenAI-compatible API avoids a dead 127.0.0.1:8081 endpoint. msg_info "Configuring LocalAGI" cat </opt/localagi/.env LOCALAGI_MODEL=gemma-3-4b-it-qat LOCALAGI_MULTIMODAL_MODEL=moondream2-20250414 LOCALAGI_IMAGE_MODEL=sd-1.5-ggml -LOCALAGI_LLM_API_URL=http://127.0.0.1:8081 +LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1 LOCALAGI_STATE_DIR=/opt/localagi/pool LOCALAGI_TIMEOUT=5m LOCALAGI_ENABLE_CONVERSATIONS_LOGGING=false From abf9c8e78b48bd12cbded75386d7bb85cb169237 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:46:36 -0500 Subject: [PATCH 021/101] feat: refactor LocalAGI backend configuration to use external-LLM mode and update disk size to 30GB --- ct/localagi.sh | 198 +---------------------------- frontend/public/json/localagi.json | 4 +- install/localagi-install.sh | 116 +---------------- 3 files changed, 10 insertions(+), 308 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 58739b96c..fed9c71ad 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -11,102 +11,17 @@ APP="LocalAGI" var_tags="${var_tags:-ai;agents}" var_cpu="${var_cpu:-4}" var_ram="${var_ram:-8192}" -var_disk="${var_disk:-60}" +var_disk="${var_disk:-30}" var_os="${var_os:-debian}" var_version="${var_version:-13}" var_unprivileged="${var_unprivileged:-1}" -var_gpu="${var_gpu:-yes}" +var_gpu="${var_gpu:-no}" header_info "$APP" variables color catch_errors -# Determine a backend override on the Proxmox host before container install. -# This avoids false CPU fallback when /dev/kfd is added after installation. -prepare_localagi_backend_override() { - if [[ -n "${var_localagi_backend:-}" && "${var_localagi_backend}" != "auto" ]]; then - export var_localagi_backend - return 0 - fi - - if [[ "${var_gpu:-no}" != "yes" ]]; then - return 0 - fi - - local detected_gpu_type="${GPU_TYPE:-}" - - if [[ -z "${detected_gpu_type}" ]]; then - if [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]]; then - detected_gpu_type="NVIDIA" - elif [[ -e /dev/kfd ]]; then - detected_gpu_type="AMD" - elif lspci 2>/dev/null | grep -qiE 'AMD|Radeon'; then - detected_gpu_type="AMD" - fi - fi - - case "${detected_gpu_type}" in - NVIDIA) - var_localagi_backend="cu128" - ;; - AMD) - var_localagi_backend="rocm7.2" - ;; - *) - return 0 - ;; - esac - - export GPU_TYPE="${detected_gpu_type}" - export var_localagi_backend - msg_info "Preselected LocalAGI backend: ${var_localagi_backend} (host GPU=${detected_gpu_type})" -} - -# Decide which runtime backend label to use for LocalAGI during updates. -# Priority: -# 1) Explicit user choice (`var_localagi_backend` or `var_torch_backend`) -# 2) Auto-detection when GPU passthrough is enabled: -# - NVIDIA device nodes => `cu128` -# - AMD KFD node => `rocm7.2` -# 3) Fallback => `cpu` -resolve_backend() { - local requested="${var_localagi_backend:-${var_torch_backend:-auto}}" - local backend="cpu" - local gpu_type="${GPU_TYPE:-unknown}" - local has_nvidia="no" - local has_kfd="no" - local has_amd_pci="no" - local has_amd_vendor="no" - - [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]] && has_nvidia="yes" - [[ -e /dev/kfd ]] && has_kfd="yes" - lspci 2>/dev/null | grep -qiE 'AMD|Radeon' && has_amd_pci="yes" - grep -qEi '0x1002|0x1022' /sys/class/drm/renderD*/device/vendor /sys/class/drm/card*/device/vendor 2>/dev/null && has_amd_vendor="yes" - - case "$requested" in - cpu | cu128 | rocm7.2) - backend="$requested" - ;; - *) - if [[ "${var_gpu:-no}" == "yes" ]]; then - if [[ "${gpu_type}" == "NVIDIA" || "${has_nvidia}" == "yes" ]]; then - backend="cu128" - elif [[ "${gpu_type}" == "AMD" || "${has_kfd}" == "yes" ]]; then - backend="rocm7.2" - elif [[ "${has_amd_pci}" == "yes" ]]; then - backend="rocm7.2" - elif [[ "${has_amd_vendor}" == "yes" ]]; then - backend="rocm7.2" - fi - fi - ;; - esac - - RESOLVED_BACKEND="$backend" - BACKEND_DETECTION_SUMMARY="requested=${requested}, var_gpu=${var_gpu:-no}, GPU_TYPE=${gpu_type}, nvidia=${has_nvidia}, kfd=${has_kfd}, amd_pci=${has_amd_pci}, amd_vendor=${has_amd_vendor}, selected=${backend}" -} - # Update or append a key=value pair inside LocalAGI environment file. # Used to keep backend and runtime flags in sync across updates. set_env_var() { @@ -133,97 +48,6 @@ build_localagi_source() { msg_ok "Built LocalAGI from source" } -# Install ROCm runtime via AMD Debian package-manager method. -# Steps: -# - Determine supported suite mapping for current Debian version -# - Install AMD signing key -# - Add ROCm and graphics repositories for 7.2 -# - Pin AMD repo origin -# - Install `rocm` meta-package -install_rocm_runtime_debian() { - if [[ -f /etc/os-release ]]; then - . /etc/os-release - fi - - local rocm_suite="" - case "${VERSION_ID:-}" in - 13*) rocm_suite="noble" ;; - 12*) rocm_suite="jammy" ;; - *) - msg_warn "Unsupported Debian version for automatic ROCm repo setup" - return 1 - ;; - esac - - msg_info "Configuring ROCm apt repositories (${rocm_suite})" - mkdir -p /etc/apt/keyrings - if ! curl -fsSL https://repo.radeon.com/rocm/rocm.gpg.key | gpg --dearmor -o /etc/apt/keyrings/rocm.gpg; then - msg_warn "Failed to add ROCm apt signing key" - return 1 - fi - - cat </etc/apt/sources.list.d/rocm.list -deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/7.2 ${rocm_suite} main -deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/graphics/7.2/ubuntu ${rocm_suite} main -EOF - - cat </etc/apt/preferences.d/rocm-pin-600 -Package: * -Pin: release o=repo.radeon.com -Pin-Priority: 600 -EOF - - msg_info "Installing ROCm runtime packages (this may take several minutes)" - $STD apt update || return 1 - $STD apt install -y rocm || return 1 - ldconfig || true - msg_ok "Installed ROCm runtime packages" -} - -ensure_localagi_kfd_passthrough() { - local backend_hint="${var_localagi_backend:-${var_torch_backend:-auto}}" - - if [[ "${var_gpu:-no}" != "yes" ]]; then - msg_warn "Skipping LocalAGI /dev/kfd passthrough: GPU passthrough is disabled" - return 0 - fi - - if [[ "${backend_hint}" != "rocm7.2" && "${GPU_TYPE:-}" != "AMD" ]]; then - msg_info "Skipping LocalAGI /dev/kfd passthrough: backend/GPU is not AMD" - return 0 - fi - - if [[ ! -e /dev/kfd ]]; then - msg_warn "Skipping LocalAGI /dev/kfd passthrough: host /dev/kfd not found" - return 0 - fi - - local lxc_config="/etc/pve/lxc/${CTID}.conf" - if [[ ! -f "${lxc_config}" ]]; then - msg_warn "Skipping LocalAGI /dev/kfd passthrough: missing ${lxc_config}" - return 0 - fi - - if grep -qE '^dev[0-9]+: /dev/kfd(,|$)' "${lxc_config}"; then - msg_ok "LocalAGI /dev/kfd passthrough already present" - return 0 - fi - - local dev_index=0 - while grep -q "^dev${dev_index}:" "${lxc_config}"; do - dev_index=$((dev_index + 1)) - done - - echo "dev${dev_index}: /dev/kfd,gid=44" >>"${lxc_config}" - msg_ok "Added LocalAGI /dev/kfd passthrough" - - if pct status "${CTID}" 2>/dev/null | grep -q running; then - msg_info "Restarting container to apply /dev/kfd passthrough" - pct reboot "${CTID}" >/dev/null 2>&1 || true - msg_ok "Container restart requested" - fi -} - function update_script() { # Standard update prechecks and environment summary. header_info @@ -262,12 +86,8 @@ function update_script() { fi fi - # Re-evaluate backend each update in case hardware/override changed. - msg_info "Resolving LocalAGI backend" - resolve_backend - BACKEND="${RESOLVED_BACKEND:-cpu}" - msg_info "Backend detection: ${BACKEND_DETECTION_SUMMARY:-unavailable}" - msg_ok "Resolved LocalAGI backend: ${BACKEND}" + BACKEND="external-llm" + msg_ok "Configured LocalAGI backend mode: ${BACKEND}" if [[ ! -f /opt/localagi/.env ]]; then msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." exit @@ -278,11 +98,6 @@ function update_script() { msg_warn "Migrated LOCALAGI_LLM_API_URL from 127.0.0.1:8081 to 127.0.0.1:11434/v1" fi - # Provision ROCm runtime only when AMD backend is selected. - if [[ "${BACKEND}" == "rocm7.2" ]]; then - install_rocm_runtime_debian || msg_warn "ROCm runtime package installation failed" - fi - # Ensure source-build toolchain exists for update rebuild step. NODE_VERSION="24" setup_nodejs GO_VERSION="latest" setup_go @@ -292,8 +107,7 @@ function update_script() { msg_ok "Installed Bun" fi - # Persist backend marker and rebuild the project from source. - set_env_var /opt/localagi/.env "LOCALAGI_GPU_BACKEND" "$BACKEND" + # Rebuild the project from source. if ! build_localagi_source; then msg_error "Failed to build LocalAGI from source" exit @@ -316,10 +130,8 @@ function update_script() { } start -prepare_localagi_backend_override build_container description -ensure_localagi_kfd_passthrough msg_ok "Completed successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index a3a247096..7b27684cc 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -21,7 +21,7 @@ "resources": { "cpu": 4, "ram": 8192, - "hdd": 60, + "hdd": 30, "os": "Debian", "version": "13" } @@ -37,7 +37,7 @@ "type": "info" }, { - "text": "GPU passthrough can be enabled during CT creation. `var_localagi_backend=cpu|cu128|rocm7.2` is recorded as `LOCALAGI_GPU_BACKEND` for your runtime setup.", + "text": "This Proxmox script runs LocalAGI in external-backend mode and does not provision local ROCm/NVIDIA runtimes.", "type": "info" }, { diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 61082c252..47d6ea803 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -25,50 +25,6 @@ if [[ -n "$header_content" ]]; then echo "$header_content" fi -# Decide which runtime backend label to use for LocalAGI. -# Priority: -# 1) Explicit user choice (`var_localagi_backend` or `var_torch_backend`) -# 2) Auto-detection when GPU passthrough is enabled: -# - NVIDIA device nodes => `cu128` -# - AMD KFD node => `rocm7.2` -# 3) Fallback => `cpu` -resolve_backend() { - local requested="${var_localagi_backend:-${var_torch_backend:-auto}}" - local backend="cpu" - local gpu_type="${GPU_TYPE:-unknown}" - local has_nvidia="no" - local has_kfd="no" - local has_amd_pci="no" - local has_amd_vendor="no" - - [[ -e /dev/nvidia0 || -e /dev/nvidiactl ]] && has_nvidia="yes" - [[ -e /dev/kfd ]] && has_kfd="yes" - lspci 2>/dev/null | grep -qiE 'AMD|Radeon' && has_amd_pci="yes" - grep -qEi '0x1002|0x1022' /sys/class/drm/renderD*/device/vendor /sys/class/drm/card*/device/vendor 2>/dev/null && has_amd_vendor="yes" - - case "$requested" in - cpu | cu128 | rocm7.2) - backend="$requested" - ;; - *) - if [[ "${var_gpu:-no}" == "yes" ]]; then - if [[ "${gpu_type}" == "NVIDIA" || "${has_nvidia}" == "yes" ]]; then - backend="cu128" - elif [[ "${gpu_type}" == "AMD" || "${has_kfd}" == "yes" ]]; then - backend="rocm7.2" - elif [[ "${has_amd_pci}" == "yes" ]]; then - backend="rocm7.2" - elif [[ "${has_amd_vendor}" == "yes" ]]; then - backend="rocm7.2" - fi - fi - ;; - esac - - RESOLVED_BACKEND="$backend" - BACKEND_DETECTION_SUMMARY="requested=${requested}, var_gpu=${var_gpu:-no}, GPU_TYPE=${gpu_type}, nvidia=${has_nvidia}, kfd=${has_kfd}, amd_pci=${has_amd_pci}, amd_vendor=${has_amd_vendor}, selected=${backend}" -} - # Build LocalAGI from source using upstream workflow: # - Build frontend in `webui/react-ui` with Bun # - Build backend binary with Go to `/usr/local/bin/localagi` @@ -141,68 +97,13 @@ install_apt_packages_resilient() { retry_cmd 2 5 apt_install_fix_missing_cmd "$@" } -# Install ROCm runtime via AMD Debian package-manager method. -# Steps: -# - Determine supported suite mapping for current Debian version -# - Install AMD signing key -# - Add ROCm and graphics repositories for 7.2 -# - Pin AMD repo origin -# - Install `rocm` meta-package -install_rocm_runtime_debian() { - if [[ -f /etc/os-release ]]; then - . /etc/os-release - fi - - local rocm_suite="" - case "${VERSION_ID:-}" in - 13*) rocm_suite="noble" ;; - 12*) rocm_suite="jammy" ;; - *) - msg_warn "Unsupported Debian version for automatic ROCm repo setup" - return 1 - ;; - esac - - msg_info "Configuring ROCm apt repositories (${rocm_suite})" - mkdir -p /etc/apt/keyrings - if ! curl -fsSL https://repo.radeon.com/rocm/rocm.gpg.key | gpg --dearmor -o /etc/apt/keyrings/rocm.gpg; then - msg_warn "Failed to add ROCm apt signing key" - return 1 - fi - - cat </etc/apt/sources.list.d/rocm.list -deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/7.2 ${rocm_suite} main -deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/graphics/7.2/ubuntu ${rocm_suite} main -EOF - - cat </etc/apt/preferences.d/rocm-pin-600 -Package: * -Pin: release o=repo.radeon.com -Pin-Priority: 600 -EOF - - msg_info "Installing ROCm runtime packages (this may take several minutes)" - if ! retry_cmd 3 5 apt_update_cmd; then - msg_warn "ROCm apt repository update failed" - return 1 - fi - if ! retry_cmd 3 10 apt_install_cmd rocm; then - msg_warn "ROCm runtime package installation failed" - return 1 - fi - ldconfig || true - msg_ok "Installed ROCm runtime packages" -} - # Install base tooling needed to fetch/build/run LocalAGI. -# `gnupg` is required for ROCm key import path. msg_info "Installing Dependencies" install_apt_packages_resilient \ curl \ ca-certificates \ git \ jq \ - gnupg \ build-essential msg_ok "Installed Dependencies" @@ -224,20 +125,10 @@ msg_info "Fetching LocalAGI Source" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" msg_ok "Fetched LocalAGI Source" -# Resolve backend and prepare persistent state directory. -msg_info "Resolving LocalAGI backend" -resolve_backend -BACKEND="${RESOLVED_BACKEND:-cpu}" -msg_info "Backend detection: ${BACKEND_DETECTION_SUMMARY:-unavailable}" +# Configure external-LLM mode and prepare persistent state directory. +BACKEND="external-llm" mkdir -p /opt/localagi/pool -msg_ok "Resolved LocalAGI backend: ${BACKEND}" - -# Only attempt ROCm runtime provisioning when AMD backend is selected. -if [[ "${BACKEND}" == "rocm7.2" ]]; then - install_rocm_runtime_debian || msg_warn "ROCm runtime package installation failed" -else - msg_warn "ROCm install skipped because selected backend is '${BACKEND}'" -fi +msg_ok "Configured LocalAGI backend mode: ${BACKEND}" # Generate runtime configuration file used by systemd service. # Note: `LOCALAGI_LLM_API_URL` points to an OpenAI-compatible backend endpoint. @@ -251,7 +142,6 @@ LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1 LOCALAGI_STATE_DIR=/opt/localagi/pool LOCALAGI_TIMEOUT=5m LOCALAGI_ENABLE_CONVERSATIONS_LOGGING=false -LOCALAGI_GPU_BACKEND=${BACKEND} EOF msg_ok "Configured LocalAGI" From c5bbc2f81d5613a95a09d4ef13228895a57a4f73 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:46:51 -0500 Subject: [PATCH 022/101] feat: update LocalAGI resource configurations to reduce RAM to 4GB and disk size to 20GB --- ct/localagi.sh | 4 ++-- frontend/public/json/localagi.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index fed9c71ad..c8a1d0254 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -10,8 +10,8 @@ source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func") APP="LocalAGI" var_tags="${var_tags:-ai;agents}" var_cpu="${var_cpu:-4}" -var_ram="${var_ram:-8192}" -var_disk="${var_disk:-30}" +var_ram="${var_ram:-4096}" +var_disk="${var_disk:-20}" var_os="${var_os:-debian}" var_version="${var_version:-13}" var_unprivileged="${var_unprivileged:-1}" diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index 7b27684cc..e7eb5bad4 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -20,8 +20,8 @@ "script": "ct/localagi.sh", "resources": { "cpu": 4, - "ram": 8192, - "hdd": 30, + "ram": 4096, + "hdd": 20, "os": "Debian", "version": "13" } From 4895935b4afac3314bd6eff4951996d9112ef58d Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:47:21 -0500 Subject: [PATCH 023/101] feat: reduce CPU allocation from 4 to 2 in LocalAGI configuration --- ct/localagi.sh | 2 +- frontend/public/json/localagi.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index c8a1d0254..37f101d83 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -9,7 +9,7 @@ source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func") APP="LocalAGI" var_tags="${var_tags:-ai;agents}" -var_cpu="${var_cpu:-4}" +var_cpu="${var_cpu:-2}" var_ram="${var_ram:-4096}" var_disk="${var_disk:-20}" var_os="${var_os:-debian}" diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index e7eb5bad4..a970100ad 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -19,7 +19,7 @@ "type": "default", "script": "ct/localagi.sh", "resources": { - "cpu": 4, + "cpu": 2, "ram": 4096, "hdd": 20, "os": "Debian", From f6cb6fa8a83b1c9ce37f60d072d2b386dd368b2e Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 00:49:42 -0500 Subject: [PATCH 024/101] feat: update interface port for LocalAGI from 8080 to 3000 --- frontend/public/json/localagi.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index a970100ad..44d6e18b1 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -8,7 +8,7 @@ "type": "ct", "updateable": true, "privileged": false, - "interface_port": 8080, + "interface_port": 3000, "documentation": "https://github.com/mudler/LocalAGI#installation-options", "website": "https://github.com/mudler/LocalAGI", "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/localagi.webp", From 614a0c008975c6c6b6a596a848a6705020423b99 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:02:22 -0500 Subject: [PATCH 025/101] fix: ensure update_script exits with error code on failure --- ct/localagi.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 37f101d83..e9a11e955 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -57,7 +57,7 @@ function update_script() { # Ensure LocalAGI source install and service exist before update flow. if [[ ! -d /opt/localagi || ! -f /etc/systemd/system/localagi.service ]]; then msg_error "No ${APP} Installation Found!" - exit + exit 1 fi # Pull latest release and refresh source tree if a new version is available. @@ -90,7 +90,7 @@ function update_script() { msg_ok "Configured LocalAGI backend mode: ${BACKEND}" if [[ ! -f /opt/localagi/.env ]]; then msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." - exit + exit 1 fi if grep -q '^LOCALAGI_LLM_API_URL=http://127.0.0.1:8081$' /opt/localagi/.env; then @@ -110,14 +110,14 @@ function update_script() { # Rebuild the project from source. if ! build_localagi_source; then msg_error "Failed to build LocalAGI from source" - exit + exit 1 fi # Restart service with rebuilt binary and current env settings. msg_info "Starting LocalAGI Service" if ! systemctl restart localagi; then msg_error "Failed to start LocalAGI service" - exit + exit 1 fi msg_ok "Started LocalAGI (${BACKEND})" From 2055148dac99c1216540a7e448c56deea84f4434 Mon Sep 17 00:00:00 2001 From: BillyOutlast <172061051+BillyOutlast@users.noreply.github.com> Date: Wed, 4 Mar 2026 10:02:59 -0500 Subject: [PATCH 026/101] Update ct/localagi.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ct/localagi.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index e9a11e955..2b7bc60dd 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -71,19 +71,23 @@ function update_script() { msg_ok "Stopped LocalAGI Service" msg_info "Backing up Environment" - cp /opt/localagi/.env /tmp/localagi.env.backup 2>/dev/null || true + local env_backup + env_backup="$(mktemp /tmp/localagi.env.XXXXXX)" + chmod 600 "$env_backup" + cp /opt/localagi/.env "$env_backup" 2>/dev/null || true msg_ok "Backed up Environment" msg_info "Updating LocalAGI" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" msg_ok "Updated LocalAGI" - if [[ -f /tmp/localagi.env.backup ]]; then + if [[ -n "${env_backup:-}" && -f "$env_backup" ]]; then msg_info "Restoring Environment" - cp /tmp/localagi.env.backup /opt/localagi/.env - rm -f /tmp/localagi.env.backup + cp "$env_backup" /opt/localagi/.env + rm -f "$env_backup" msg_ok "Restored Environment" fi + fi fi BACKEND="external-llm" From 931af9585545b46d0b30a5c679bd3c12bfd9fc6e Mon Sep 17 00:00:00 2001 From: BillyOutlast <172061051+BillyOutlast@users.noreply.github.com> Date: Wed, 4 Mar 2026 10:03:30 -0500 Subject: [PATCH 027/101] Update install/localagi-install.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- install/localagi-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 47d6ea803..5c4158944 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -143,6 +143,7 @@ LOCALAGI_STATE_DIR=/opt/localagi/pool LOCALAGI_TIMEOUT=5m LOCALAGI_ENABLE_CONVERSATIONS_LOGGING=false EOF +chmod 600 /opt/localagi/.env msg_ok "Configured LocalAGI" # Build source tree into executable binary. From fd820b026b4ec65840e40fc5357678188049350f Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:05:58 -0500 Subject: [PATCH 028/101] refactor: remove set_env_var function and streamline LOCALAGI_LLM_API_URL migration logic --- ct/localagi.sh | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 2b7bc60dd..8109024de 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -22,19 +22,6 @@ variables color catch_errors -# Update or append a key=value pair inside LocalAGI environment file. -# Used to keep backend and runtime flags in sync across updates. -set_env_var() { - local env_file="$1" - local key="$2" - local value="$3" - if grep -q "^${key}=" "$env_file"; then - sed -i "s|^${key}=.*|${key}=${value}|" "$env_file" - else - echo "${key}=${value}" >>"$env_file" - fi -} - # Build LocalAGI from source using upstream workflow: # - Build frontend in `webui/react-ui` with Bun # - Build backend binary with Go to `/usr/local/bin/localagi` @@ -87,7 +74,6 @@ function update_script() { rm -f "$env_backup" msg_ok "Restored Environment" fi - fi fi BACKEND="external-llm" @@ -98,7 +84,11 @@ function update_script() { fi if grep -q '^LOCALAGI_LLM_API_URL=http://127.0.0.1:8081$' /opt/localagi/.env; then - set_env_var /opt/localagi/.env "LOCALAGI_LLM_API_URL" "http://127.0.0.1:11434/v1" + if grep -q '^LOCALAGI_LLM_API_URL=' /opt/localagi/.env; then + sed -i 's|^LOCALAGI_LLM_API_URL=.*|LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1|' /opt/localagi/.env + else + echo "LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1" >>/opt/localagi/.env + fi msg_warn "Migrated LOCALAGI_LLM_API_URL from 127.0.0.1:8081 to 127.0.0.1:11434/v1" fi From 610d12be9c19466242737b746172fe359a2e3533 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:06:53 -0500 Subject: [PATCH 029/101] refactor: streamline LocalAGI build process in update_script function --- ct/localagi.sh | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 8109024de..9c3c93856 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -22,19 +22,6 @@ variables color catch_errors -# Build LocalAGI from source using upstream workflow: -# - Build frontend in `webui/react-ui` with Bun -# - Build backend binary with Go to `/usr/local/bin/localagi` -build_localagi_source() { - msg_info "Building LocalAGI from source" - cd /opt/localagi/webui/react-ui || return 1 - $STD bun install || return 1 - $STD bun run build || return 1 - cd /opt/localagi || return 1 - $STD go build -o /usr/local/bin/localagi || return 1 - msg_ok "Built LocalAGI from source" -} - function update_script() { # Standard update prechecks and environment summary. header_info @@ -102,10 +89,18 @@ function update_script() { fi # Rebuild the project from source. - if ! build_localagi_source; then + msg_info "Building LocalAGI from source" + if ! ( + cd /opt/localagi/webui/react-ui && + $STD bun install && + $STD bun run build && + cd /opt/localagi && + $STD go build -o /usr/local/bin/localagi + ); then msg_error "Failed to build LocalAGI from source" exit 1 fi + msg_ok "Built LocalAGI from source" # Restart service with rebuilt binary and current env settings. msg_info "Starting LocalAGI Service" From 86d22a060a32e778bceb3d6f168482b399fe953a Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:08:45 -0500 Subject: [PATCH 030/101] refactor: simplify update_script function by removing redundant comments and streamlining logic --- ct/localagi.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 9c3c93856..b91b60cb3 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -23,23 +23,19 @@ color catch_errors function update_script() { - # Standard update prechecks and environment summary. header_info check_container_storage check_container_resources - # Ensure LocalAGI source install and service exist before update flow. if [[ ! -d /opt/localagi || ! -f /etc/systemd/system/localagi.service ]]; then msg_error "No ${APP} Installation Found!" exit 1 fi - # Pull latest release and refresh source tree if a new version is available. local update_performed="no" if check_for_gh_release "localagi" "mudler/LocalAGI"; then update_performed="yes" - # Stop service and preserve runtime env before replacing source tree. msg_info "Stopping LocalAGI Service" systemctl stop localagi msg_ok "Stopped LocalAGI Service" @@ -79,7 +75,6 @@ function update_script() { msg_warn "Migrated LOCALAGI_LLM_API_URL from 127.0.0.1:8081 to 127.0.0.1:11434/v1" fi - # Ensure source-build toolchain exists for update rebuild step. NODE_VERSION="24" setup_nodejs GO_VERSION="latest" setup_go if ! command -v bun >/dev/null 2>&1; then @@ -88,7 +83,6 @@ function update_script() { msg_ok "Installed Bun" fi - # Rebuild the project from source. msg_info "Building LocalAGI from source" if ! ( cd /opt/localagi/webui/react-ui && @@ -102,7 +96,6 @@ function update_script() { fi msg_ok "Built LocalAGI from source" - # Restart service with rebuilt binary and current env settings. msg_info "Starting LocalAGI Service" if ! systemctl restart localagi; then msg_error "Failed to start LocalAGI service" From 6261ee8c34dee2c29fe8027d2a8f6af55f07f04f Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:10:05 -0500 Subject: [PATCH 031/101] refactor: streamline localagi-install.sh by removing redundant comments and simplifying build process --- install/localagi-install.sh | 114 ++++-------------------------------- 1 file changed, 11 insertions(+), 103 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 5c4158944..43a92979c 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -7,99 +7,15 @@ source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" APP="LocalAGI" - -# Load common UI/helpers and perform standard container bootstrap lifecycle. -# - `color`, `verb_ip6`, `catch_errors`: logging/error behavior -# - `setting_up_container`, `network_check`, `update_os`: baseline prep/update color verb_ip6 catch_errors setting_up_container network_check update_os -header_content="" -if declare -f get_header >/dev/null 2>&1; then - header_content=$(get_header 2>/dev/null || true) -fi -if [[ -n "$header_content" ]]; then - echo "$header_content" -fi -# Build LocalAGI from source using upstream workflow: -# - Build frontend in `webui/react-ui` with Bun -# - Build backend binary with Go to `/usr/local/bin/localagi` -build_localagi_source() { - msg_info "Building LocalAGI from source" - cd /opt/localagi/webui/react-ui || return 1 - $STD bun install || return 1 - $STD bun run build || return 1 - cd /opt/localagi || return 1 - $STD go build -o /usr/local/bin/localagi || return 1 - msg_ok "Built LocalAGI from source" -} - -# Generic command retry helper with linear backoff. -# Usage: retry_cmd [args...] -retry_cmd() { - local max_attempts="$1" - local base_delay="$2" - shift 2 - local attempt=1 - while [[ $attempt -le $max_attempts ]]; do - if "$@"; then - return 0 - fi - if [[ $attempt -lt $max_attempts ]]; then - msg_warn "Command failed (attempt ${attempt}/${max_attempts}): $*" - sleep $((base_delay * attempt)) - fi - attempt=$((attempt + 1)) - done - return 1 -} - -# Recovery path for transient apt repository/index failures. -# Especially useful for Hash Sum mismatch and stale list states. -apt_recover_indexes() { - rm -rf /var/lib/apt/lists/partial/* /var/lib/apt/lists/* 2>/dev/null || true - $STD apt clean - $STD apt update -} - -# Small wrappers so retry helper executes apt commands in current shell context. -# This avoids subshell issues with helper wrappers like `$STD` (e.g. `silent`). -apt_update_cmd() { - $STD apt update -} - -apt_install_cmd() { - $STD apt install -y "$@" -} - -apt_install_fix_missing_cmd() { - $STD apt install -y --fix-missing "$@" -} - -# Resilient package install flow: -# 1) Retry normal install -# 2) If still failing, clean apt state + refresh indexes -# 3) Retry with `--fix-missing` -install_apt_packages_resilient() { - if retry_cmd 3 5 apt_install_cmd "$@"; then - return 0 - fi - - msg_warn "APT install failed; attempting index recovery and retry" - if ! retry_cmd 2 5 apt_recover_indexes; then - return 1 - fi - - retry_cmd 2 5 apt_install_fix_missing_cmd "$@" -} - -# Install base tooling needed to fetch/build/run LocalAGI. msg_info "Installing Dependencies" -install_apt_packages_resilient \ +$STD apt install -y \ curl \ ca-certificates \ git \ @@ -107,32 +23,21 @@ install_apt_packages_resilient \ build-essential msg_ok "Installed Dependencies" -# Install language/runtime toolchains used by LocalAGI source build. -# - Node.js: frontend/Bun ecosystem compatibility -# - Go: backend binary build NODE_VERSION="24" setup_nodejs GO_VERSION="latest" setup_go -# Install Bun package manager (if not already present). msg_info "Installing Bun" -if ! command -v bun >/dev/null 2>&1; then - $STD npm install -g bun -fi +$STD npm install -g bun msg_ok "Installed Bun" -# Pull latest LocalAGI source snapshot from GitHub release tarball. msg_info "Fetching LocalAGI Source" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" msg_ok "Fetched LocalAGI Source" -# Configure external-LLM mode and prepare persistent state directory. BACKEND="external-llm" mkdir -p /opt/localagi/pool msg_ok "Configured LocalAGI backend mode: ${BACKEND}" -# Generate runtime configuration file used by systemd service. -# Note: `LOCALAGI_LLM_API_URL` points to an OpenAI-compatible backend endpoint. -# Defaulting to Ollama's OpenAI-compatible API avoids a dead 127.0.0.1:8081 endpoint. msg_info "Configuring LocalAGI" cat </opt/localagi/.env LOCALAGI_MODEL=gemma-3-4b-it-qat @@ -146,14 +51,19 @@ EOF chmod 600 /opt/localagi/.env msg_ok "Configured LocalAGI" -# Build source tree into executable binary. -if ! build_localagi_source; then +msg_info "Building LocalAGI from source" +if ! ( + cd /opt/localagi/webui/react-ui && + $STD bun install && + $STD bun run build && + cd /opt/localagi && + $STD go build -o /usr/local/bin/localagi +); then msg_error "Failed to build LocalAGI from source" exit 1 fi +msg_ok "Built LocalAGI from source" -# Create and start systemd unit for LocalAGI. -# The service reads `/opt/localagi/.env` at runtime. msg_info "Creating Service" cat </etc/systemd/system/localagi.service [Unit] @@ -175,14 +85,12 @@ systemctl daemon-reload systemctl enable -q --now localagi msg_ok "Created Service" -# Verify service health before exiting installer. if ! systemctl is-active -q localagi; then msg_error "Failed to start LocalAGI service" exit 1 fi msg_ok "Started LocalAGI (${BACKEND})" -# Standard post-install housekeeping from shared framework. motd_ssh customize cleanup_lxc From 521c74d2badb1b33bf04019df37a0e6fe386c69c Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:16:45 -0500 Subject: [PATCH 032/101] refactor: simplify localagi.sh by removing redundant variables and streamlining update_script function --- ct/localagi.sh | 79 ++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index b91b60cb3..05adb3102 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-${COMMUNITY_SCRIPT_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main}}" -source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func") +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: GitHub Copilot @@ -32,10 +31,7 @@ function update_script() { exit 1 fi - local update_performed="no" if check_for_gh_release "localagi" "mudler/LocalAGI"; then - update_performed="yes" - msg_info "Stopping LocalAGI Service" systemctl stop localagi msg_ok "Stopped LocalAGI Service" @@ -57,56 +53,49 @@ function update_script() { rm -f "$env_backup" msg_ok "Restored Environment" fi - fi - BACKEND="external-llm" - msg_ok "Configured LocalAGI backend mode: ${BACKEND}" - if [[ ! -f /opt/localagi/.env ]]; then - msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." - exit 1 - fi - - if grep -q '^LOCALAGI_LLM_API_URL=http://127.0.0.1:8081$' /opt/localagi/.env; then - if grep -q '^LOCALAGI_LLM_API_URL=' /opt/localagi/.env; then - sed -i 's|^LOCALAGI_LLM_API_URL=.*|LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1|' /opt/localagi/.env - else - echo "LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1" >>/opt/localagi/.env + msg_ok "Configured LocalAGI backend mode: external-llm" + if [[ ! -f /opt/localagi/.env ]]; then + msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." + exit 1 fi - msg_warn "Migrated LOCALAGI_LLM_API_URL from 127.0.0.1:8081 to 127.0.0.1:11434/v1" - fi - NODE_VERSION="24" setup_nodejs - GO_VERSION="latest" setup_go - if ! command -v bun >/dev/null 2>&1; then + if grep -q '^LOCALAGI_LLM_API_URL=http://127.0.0.1:8081$' /opt/localagi/.env; then + if grep -q '^LOCALAGI_LLM_API_URL=' /opt/localagi/.env; then + sed -i 's|^LOCALAGI_LLM_API_URL=.*|LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1|' /opt/localagi/.env + else + echo "LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1" >>/opt/localagi/.env + fi + msg_warn "Migrated LOCALAGI_LLM_API_URL from 127.0.0.1:8081 to 127.0.0.1:11434/v1" + fi + + NODE_VERSION="24" setup_nodejs + setup_go msg_info "Installing Bun" $STD npm install -g bun msg_ok "Installed Bun" - fi - msg_info "Building LocalAGI from source" - if ! ( - cd /opt/localagi/webui/react-ui && - $STD bun install && - $STD bun run build && - cd /opt/localagi && - $STD go build -o /usr/local/bin/localagi - ); then - msg_error "Failed to build LocalAGI from source" - exit 1 - fi - msg_ok "Built LocalAGI from source" + msg_info "Building LocalAGI from source" + ( + cd /opt/localagi/webui/react-ui && + $STD bun install && + $STD bun run build && + cd /opt/localagi && + $STD go build -o /usr/local/bin/localagi + ) || { + msg_error "Failed to build LocalAGI from source" + exit 1 + } + msg_ok "Built LocalAGI from source" - msg_info "Starting LocalAGI Service" - if ! systemctl restart localagi; then - msg_error "Failed to start LocalAGI service" - exit 1 - fi - msg_ok "Started LocalAGI (${BACKEND})" + msg_info "Starting LocalAGI Service" + systemctl restart localagi || { + msg_error "Failed to start LocalAGI service" + exit 1 + } + msg_ok "Started LocalAGI (external-llm)" - if [[ "$update_performed" == "yes" ]]; then msg_ok "Updated successfully!" - else - msg_ok "No update required. Rebuilt source and restarted service." fi exit } From dc7d9fcb82dc20de2b9f276d5c828bfd58fe5e8f Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:24:37 -0500 Subject: [PATCH 033/101] refactor: update log message for backend mode configuration in update_script function --- ct/localagi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 05adb3102..678028961 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -54,7 +54,7 @@ function update_script() { msg_ok "Restored Environment" fi - msg_ok "Configured LocalAGI backend mode: external-llm" + msg_ok "Backend mode: external-llm" if [[ ! -f /opt/localagi/.env ]]; then msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." exit 1 From 90fc8fb1c76792c19648a1e3386b007bc37e0729 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:30:43 -0500 Subject: [PATCH 034/101] refactor: simplify localagi-install.sh by removing GO_VERSION variable from setup_go --- install/localagi-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 43a92979c..582806d36 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -24,7 +24,7 @@ $STD apt install -y \ msg_ok "Installed Dependencies" NODE_VERSION="24" setup_nodejs -GO_VERSION="latest" setup_go +setup_go msg_info "Installing Bun" $STD npm install -g bun From 2e7e6507f6c3de0ef346cd2434ec8fcc3b4b89fb Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:38:12 -0500 Subject: [PATCH 035/101] refactor: remove redundant IP address retrieval logic from localagi.sh --- ct/localagi.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 678028961..83a98dca2 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -107,21 +107,3 @@ description msg_ok "Completed successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" - -if [[ -z "${IP:-}" ]]; then - IP=$(pct exec "$CTID" -- sh -c "hostname -I 2>/dev/null | tr ' ' '\n' | grep -E '^[0-9]+\.' | head -n1") -fi -if [[ -z "${IP:-}" ]]; then - IP=$(pct exec "$CTID" -- sh -c "hostname -I 2>/dev/null | tr ' ' '\n' | grep -E ':' | head -n1") -fi - -URL_HOST="${IP:-}" -if [[ -n "${URL_HOST}" && "${URL_HOST}" == *:* ]]; then - URL_HOST="[${URL_HOST}]" -fi -if [[ -z "${URL_HOST}" ]]; then - msg_warn "Unable to determine container IP automatically" - echo -e "${TAB}${GATEWAY}${BGN}http://:3000${CL}" -else - echo -e "${TAB}${GATEWAY}${BGN}http://${URL_HOST}:3000${CL}" -fi From 8db69a2dd7eda561520010b52b791327fbee9703 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:41:02 -0500 Subject: [PATCH 036/101] fix: add missing URL output for LocalAGI setup completion --- ct/localagi.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index 83a98dca2..5a2772ba2 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -107,3 +107,4 @@ description msg_ok "Completed successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}" From c37926116893660bd89e7a6da67441b7413fab1c Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:42:01 -0500 Subject: [PATCH 037/101] fix: update author information in localagi.sh and localagi-install.sh --- ct/localagi.sh | 2 +- install/localagi-install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 5a2772ba2..e12961e37 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -2,7 +2,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG -# Author: GitHub Copilot +# Author: BillyOutlast # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE # Source: https://github.com/mudler/LocalAGI diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 582806d36..608089cca 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Copyright (c) 2021-2026 community-scripts ORG -# Author: GitHub Copilot +# Author: BillyOutlast # License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE # Source: https://github.com/mudler/LocalAGI From 2797550b7ebd192dd5fd745282f2d58a7467164c Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:43:50 -0500 Subject: [PATCH 038/101] fix: implement cleanup function for LocalAGI service recovery during updates --- ct/localagi.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index e12961e37..aea5a2c85 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -21,7 +21,23 @@ variables color catch_errors +LOCALAGI_WAS_STOPPED=0 + +function cleanup_localagi_service() { + if [[ "${LOCALAGI_WAS_STOPPED:-0}" == "1" ]] && ! systemctl is-active -q localagi; then + msg_warn "LocalAGI service was stopped during update; attempting recovery start" + if systemctl start localagi; then + msg_ok "Recovered LocalAGI service" + else + msg_error "Failed to recover LocalAGI service" + fi + fi +} + function update_script() { + LOCALAGI_WAS_STOPPED=0 + trap cleanup_localagi_service EXIT + header_info check_container_storage check_container_resources @@ -34,6 +50,7 @@ function update_script() { if check_for_gh_release "localagi" "mudler/LocalAGI"; then msg_info "Stopping LocalAGI Service" systemctl stop localagi + LOCALAGI_WAS_STOPPED=1 msg_ok "Stopped LocalAGI Service" msg_info "Backing up Environment" @@ -93,6 +110,7 @@ function update_script() { msg_error "Failed to start LocalAGI service" exit 1 } + LOCALAGI_WAS_STOPPED=0 msg_ok "Started LocalAGI (external-llm)" msg_ok "Updated successfully!" From b2fd9b23b7db62b278ab645c4c9ec98eb7078abb Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:44:10 -0500 Subject: [PATCH 039/101] fix: implement recovery mechanism for LocalAGI service during installation --- install/localagi-install.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 608089cca..e5e865fbe 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -14,6 +14,21 @@ setting_up_container network_check update_os +LOCALAGI_SERVICE_NEEDS_RECOVERY=0 + +function cleanup_localagi_service() { + if [[ "${LOCALAGI_SERVICE_NEEDS_RECOVERY:-0}" == "1" ]] && ! systemctl is-active -q localagi; then + msg_warn "LocalAGI service is not active; attempting recovery start" + if systemctl start localagi; then + msg_ok "Recovered LocalAGI service" + else + msg_error "Failed to recover LocalAGI service" + fi + fi +} + +trap cleanup_localagi_service EXIT + msg_info "Installing Dependencies" $STD apt install -y \ curl \ @@ -82,6 +97,7 @@ RestartSec=5 WantedBy=multi-user.target EOF systemctl daemon-reload +LOCALAGI_SERVICE_NEEDS_RECOVERY=1 systemctl enable -q --now localagi msg_ok "Created Service" @@ -89,6 +105,7 @@ if ! systemctl is-active -q localagi; then msg_error "Failed to start LocalAGI service" exit 1 fi +LOCALAGI_SERVICE_NEEDS_RECOVERY=0 msg_ok "Started LocalAGI (${BACKEND})" motd_ssh From ebdb4db5e51be0d5037e7da51c9c16898803f1ec Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 10:45:58 -0500 Subject: [PATCH 040/101] fix: enhance environment backup validation during LocalAGI updates --- ct/localagi.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index aea5a2c85..b46eca0c4 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -55,16 +55,27 @@ function update_script() { msg_info "Backing up Environment" local env_backup - env_backup="$(mktemp /tmp/localagi.env.XXXXXX)" - chmod 600 "$env_backup" - cp /opt/localagi/.env "$env_backup" 2>/dev/null || true - msg_ok "Backed up Environment" + local env_backup_valid=0 + if [[ -s /opt/localagi/.env ]]; then + env_backup="$(mktemp /tmp/localagi.env.XXXXXX)" + chmod 600 "$env_backup" + if cp /opt/localagi/.env "$env_backup" 2>/dev/null && [[ -s "$env_backup" ]]; then + env_backup_valid=1 + msg_ok "Backed up Environment" + else + rm -f "$env_backup" + env_backup="" + msg_warn "Failed to create valid environment backup" + fi + else + msg_warn "Skipping environment backup: /opt/localagi/.env missing or empty" + fi msg_info "Updating LocalAGI" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" msg_ok "Updated LocalAGI" - if [[ -n "${env_backup:-}" && -f "$env_backup" ]]; then + if [[ "${env_backup_valid:-0}" == "1" && -n "${env_backup:-}" && -s "$env_backup" ]]; then msg_info "Restoring Environment" cp "$env_backup" /opt/localagi/.env rm -f "$env_backup" From c4019eeeb53a4dec0417674302bffba63e4adbc2 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 12:13:40 -0500 Subject: [PATCH 041/101] fix: add header creation logic for LocalAGI setup --- ct/localagi.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index b46eca0c4..9edc64bf9 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -16,6 +16,19 @@ var_version="${var_version:-13}" var_unprivileged="${var_unprivileged:-1}" var_gpu="${var_gpu:-no}" +LOCALAGI_HEADER_PATH="/usr/local/community-scripts/headers/ct/localagi" +if [[ ! -s "$LOCALAGI_HEADER_PATH" ]]; then + mkdir -p "$(dirname "$LOCALAGI_HEADER_PATH")" + cat <<'EOF' >"$LOCALAGI_HEADER_PATH" + __ __ ___ __________ + / / ____ ________ _/ / / | / ____/ _/ + / / / __ \/ ___/ __ `/ / / /| |/ / __ / / + / /___/ /_/ / /__/ /_/ / / / ___ / /_/ // / +/_____/\____/\___/\__,_/_/ /_/ |_\____/___/ + +EOF +fi + header_info "$APP" variables color From eb95857830ce8f104d8467c506e26611d7ef298c Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 12:15:50 -0500 Subject: [PATCH 042/101] fix: update COMMUNITY_SCRIPTS_URL assignment in localagi.sh --- ct/localagi.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 9edc64bf9..5391f58f8 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-${COMMUNITY_SCRIPT_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main}}" +source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func") # Copyright (c) 2021-2026 community-scripts ORG # Author: BillyOutlast From 45fd4d2d9896856d28888291dc1594c87e3b0875 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 12:17:58 -0500 Subject: [PATCH 043/101] fix: remove dynamic COMMUNITY_SCRIPTS_URL assignment and header creation logic in localagi.sh --- ct/localagi.sh | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 5391f58f8..b46eca0c4 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-${COMMUNITY_SCRIPT_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main}}" -source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func") +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: BillyOutlast @@ -17,19 +16,6 @@ var_version="${var_version:-13}" var_unprivileged="${var_unprivileged:-1}" var_gpu="${var_gpu:-no}" -LOCALAGI_HEADER_PATH="/usr/local/community-scripts/headers/ct/localagi" -if [[ ! -s "$LOCALAGI_HEADER_PATH" ]]; then - mkdir -p "$(dirname "$LOCALAGI_HEADER_PATH")" - cat <<'EOF' >"$LOCALAGI_HEADER_PATH" - __ __ ___ __________ - / / ____ ________ _/ / / | / ____/ _/ - / / / __ \/ ___/ __ `/ / / /| |/ / __ / / - / /___/ /_/ / /__/ /_/ / / / ___ / /_/ // / -/_____/\____/\___/\__,_/_/ /_/ |_\____/___/ - -EOF -fi - header_info "$APP" variables color From 13aab6df0566ccc87bf8b5b4bf1a917f776d9838 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 12:22:48 -0500 Subject: [PATCH 044/101] fix: add curl function with debug logging for error handling in localagi.sh --- ct/localagi.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index b46eca0c4..8104a8c39 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -21,6 +21,31 @@ variables color catch_errors +LOCALAGI_DEBUG_CURL_LOG="/tmp/localagi-curl-debug.log" + +function curl() { + command curl "$@" + local curl_rc=$? + + if [[ "$curl_rc" -ne 0 && "${LOCALAGI_DEBUG_CURL:-1}" == "1" ]]; then + local curl_url="" + local arg + for arg in "$@"; do + if [[ "$arg" =~ ^https?:// ]]; then + curl_url="$arg" + fi + done + + local debug_line + debug_line="[$(date '+%Y-%m-%dT%H:%M:%S%z')] curl failed rc=${curl_rc} url=${curl_url:-unknown} args=$*" + echo "$debug_line" | tee -a "$LOCALAGI_DEBUG_CURL_LOG" >&2 + fi + + return "$curl_rc" +} + +msg_info "Curl debug enabled (log: ${LOCALAGI_DEBUG_CURL_LOG})" + LOCALAGI_WAS_STOPPED=0 function cleanup_localagi_service() { From d15ef86fab77c70e59198106d10befceb686ce18 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 12:23:23 -0500 Subject: [PATCH 045/101] fix: remove curl debug logging function and related variable in localagi.sh --- ct/localagi.sh | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 8104a8c39..b46eca0c4 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -21,31 +21,6 @@ variables color catch_errors -LOCALAGI_DEBUG_CURL_LOG="/tmp/localagi-curl-debug.log" - -function curl() { - command curl "$@" - local curl_rc=$? - - if [[ "$curl_rc" -ne 0 && "${LOCALAGI_DEBUG_CURL:-1}" == "1" ]]; then - local curl_url="" - local arg - for arg in "$@"; do - if [[ "$arg" =~ ^https?:// ]]; then - curl_url="$arg" - fi - done - - local debug_line - debug_line="[$(date '+%Y-%m-%dT%H:%M:%S%z')] curl failed rc=${curl_rc} url=${curl_url:-unknown} args=$*" - echo "$debug_line" | tee -a "$LOCALAGI_DEBUG_CURL_LOG" >&2 - fi - - return "$curl_rc" -} - -msg_info "Curl debug enabled (log: ${LOCALAGI_DEBUG_CURL_LOG})" - LOCALAGI_WAS_STOPPED=0 function cleanup_localagi_service() { From 00db7c9fcfc219cc37d1af6df7d4f50ab9015bf0 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 12:24:55 -0500 Subject: [PATCH 046/101] fix: update COMMUNITY_SCRIPTS_URL assignment for dynamic sourcing in localagi.sh --- ct/localagi.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index b46eca0c4..9b459a404 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-${COMMUNITY_SCRIPT_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main}}" +source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func") # Copyright (c) 2021-2026 community-scripts ORG # Author: BillyOutlast From 975f5bcbbe6ced8f3c28a474201ab07743dbd351 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 12:27:25 -0500 Subject: [PATCH 047/101] fix: remove dynamic COMMUNITY_SCRIPTS_URL assignment in localagi.sh --- ct/localagi.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 9b459a404..b46eca0c4 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-${COMMUNITY_SCRIPT_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main}}" -source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/build.func") +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: BillyOutlast From 87cb94c8ca4bef1961566a3929c475259ed41a63 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 12:29:44 -0500 Subject: [PATCH 048/101] fix: update URL output format in localagi.sh to include port number --- ct/localagi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index b46eca0c4..6c8ee7ab8 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -136,4 +136,4 @@ description msg_ok "Completed successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" From 99b1a773dc9f366c2f4fc81c762ef24c5545a51d Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 15:40:13 -0500 Subject: [PATCH 049/101] fix: remove cleanup function and related logic for LocalAGI service recovery in localagi.sh --- ct/localagi.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 6c8ee7ab8..6be6bc58d 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -21,23 +21,7 @@ variables color catch_errors -LOCALAGI_WAS_STOPPED=0 - -function cleanup_localagi_service() { - if [[ "${LOCALAGI_WAS_STOPPED:-0}" == "1" ]] && ! systemctl is-active -q localagi; then - msg_warn "LocalAGI service was stopped during update; attempting recovery start" - if systemctl start localagi; then - msg_ok "Recovered LocalAGI service" - else - msg_error "Failed to recover LocalAGI service" - fi - fi -} - function update_script() { - LOCALAGI_WAS_STOPPED=0 - trap cleanup_localagi_service EXIT - header_info check_container_storage check_container_resources @@ -50,7 +34,6 @@ function update_script() { if check_for_gh_release "localagi" "mudler/LocalAGI"; then msg_info "Stopping LocalAGI Service" systemctl stop localagi - LOCALAGI_WAS_STOPPED=1 msg_ok "Stopped LocalAGI Service" msg_info "Backing up Environment" @@ -121,7 +104,6 @@ function update_script() { msg_error "Failed to start LocalAGI service" exit 1 } - LOCALAGI_WAS_STOPPED=0 msg_ok "Started LocalAGI (external-llm)" msg_ok "Updated successfully!" From 99190f8fa66d9bcfe79e40c4b44b7ebb961fc919 Mon Sep 17 00:00:00 2001 From: BillyOutlast <172061051+BillyOutlast@users.noreply.github.com> Date: Wed, 4 Mar 2026 15:48:06 -0500 Subject: [PATCH 050/101] Update install/localagi-install.sh Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- install/localagi-install.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index e5e865fbe..e747055f9 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -45,9 +45,7 @@ msg_info "Installing Bun" $STD npm install -g bun msg_ok "Installed Bun" -msg_info "Fetching LocalAGI Source" -CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" -msg_ok "Fetched LocalAGI Source" +fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" BACKEND="external-llm" mkdir -p /opt/localagi/pool From fb6a07611bec46570e5de8ccceb05c04e5d810d5 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 15:48:12 -0500 Subject: [PATCH 051/101] fix: simplify dependency installation by removing unnecessary packages in localagi-install.sh --- install/localagi-install.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index e5e865fbe..a76036728 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -30,12 +30,7 @@ function cleanup_localagi_service() { trap cleanup_localagi_service EXIT msg_info "Installing Dependencies" -$STD apt install -y \ - curl \ - ca-certificates \ - git \ - jq \ - build-essential +$STD apt install -y build-essential msg_ok "Installed Dependencies" NODE_VERSION="24" setup_nodejs From 5b865bba63ebc63d6a500b5045d76f2ac4723e67 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 15:50:38 -0500 Subject: [PATCH 052/101] fix: remove backend mode configuration from LocalAGI installation script --- install/localagi-install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index b4f148a1c..baad95c1d 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -42,9 +42,7 @@ msg_ok "Installed Bun" fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" -BACKEND="external-llm" mkdir -p /opt/localagi/pool -msg_ok "Configured LocalAGI backend mode: ${BACKEND}" msg_info "Configuring LocalAGI" cat </opt/localagi/.env @@ -99,7 +97,6 @@ if ! systemctl is-active -q localagi; then exit 1 fi LOCALAGI_SERVICE_NEEDS_RECOVERY=0 -msg_ok "Started LocalAGI (${BACKEND})" motd_ssh customize From a5c85d465cd07c064a93d8ad3a6c02fa4c381998 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 15:52:02 -0500 Subject: [PATCH 053/101] fix: remove service recovery logic from LocalAGI installation script --- install/localagi-install.sh | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index baad95c1d..5e1b773c0 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -14,20 +14,6 @@ setting_up_container network_check update_os -LOCALAGI_SERVICE_NEEDS_RECOVERY=0 - -function cleanup_localagi_service() { - if [[ "${LOCALAGI_SERVICE_NEEDS_RECOVERY:-0}" == "1" ]] && ! systemctl is-active -q localagi; then - msg_warn "LocalAGI service is not active; attempting recovery start" - if systemctl start localagi; then - msg_ok "Recovered LocalAGI service" - else - msg_error "Failed to recover LocalAGI service" - fi - fi -} - -trap cleanup_localagi_service EXIT msg_info "Installing Dependencies" $STD apt install -y build-essential @@ -96,7 +82,6 @@ if ! systemctl is-active -q localagi; then msg_error "Failed to start LocalAGI service" exit 1 fi -LOCALAGI_SERVICE_NEEDS_RECOVERY=0 motd_ssh customize From f9eea806ddc718476f5cbdf6c9b1d8d6133ceb6b Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 15:53:30 -0500 Subject: [PATCH 054/101] fix: simplify LocalAGI build process by removing error handling --- install/localagi-install.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 5e1b773c0..7c79bea17 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -44,16 +44,12 @@ chmod 600 /opt/localagi/.env msg_ok "Configured LocalAGI" msg_info "Building LocalAGI from source" -if ! ( - cd /opt/localagi/webui/react-ui && - $STD bun install && - $STD bun run build && - cd /opt/localagi && - $STD go build -o /usr/local/bin/localagi -); then - msg_error "Failed to build LocalAGI from source" - exit 1 -fi + +cd /opt/localagi/webui/react-ui && + $STD bun install && + $STD bun run build && + cd /opt/localagi && + $STD go build -o /usr/local/bin/localagi msg_ok "Built LocalAGI from source" msg_info "Creating Service" From d0803f96d8adf980309501481711f8c94ad7bd4f Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:41:07 -0500 Subject: [PATCH 055/101] feat: enhance LocalAGI installation with user creation and service hardening --- frontend/public/json/localagi.json | 5 ++++ install/localagi-install.sh | 41 ++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index 44d6e18b1..e01439467 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -48,5 +48,10 @@ "text": "To use an external Ollama host, edit `/opt/localagi/.env` and set `LOCALAGI_LLM_API_URL=http://:11434/v1`, then restart LocalAGI with `systemctl restart localagi`.", "type": "info" } + , + { + "text": "The service runs as a dedicated system user `localagi` and the unit includes basic hardening (NoNewPrivileges, PrivateTmp, ProtectSystem).", + "type": "info" + } ] } diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 7c79bea17..2d914f1c9 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -28,6 +28,11 @@ msg_ok "Installed Bun" fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" +if [[ ! -d /opt/localagi/webui/react-ui ]]; then + msg_error "Unexpected release layout: /opt/localagi/webui/react-ui not found" + exit 1 +fi + mkdir -p /opt/localagi/pool msg_info "Configuring LocalAGI" @@ -45,11 +50,29 @@ msg_ok "Configured LocalAGI" msg_info "Building LocalAGI from source" -cd /opt/localagi/webui/react-ui && - $STD bun install && - $STD bun run build && - cd /opt/localagi && - $STD go build -o /usr/local/bin/localagi +# Create dedicated system user to run the service +if ! id -u localagi >/dev/null 2>&1; then + msg_info "Creating system user 'localagi'" + useradd --system --no-create-home --shell /usr/sbin/nologin --home /opt/localagi localagi || \ + msg_warn "Failed to create 'localagi' user; continuing if it already exists" +fi + +# Ensure ownership and perms +chown -R localagi:localagi /opt/localagi || msg_warn "Failed to chown /opt/localagi" + +cd /opt/localagi/webui/react-ui || { msg_error "Missing webui/react-ui directory"; exit 1; } + +msg_info "Running bun install" +$STD bun install || { msg_error "bun install failed"; exit 1; } + +msg_info "Building web UI" +$STD bun run build || { msg_error "bun build failed"; exit 1; } + +cd /opt/localagi || { msg_error "Missing /opt/localagi"; exit 1; } + +msg_info "Building Go binary" +$STD go build -o /usr/local/bin/localagi || { msg_error "go build failed"; exit 1; } +chmod 755 /usr/local/bin/localagi || msg_warn "Failed to chmod /usr/local/bin/localagi" msg_ok "Built LocalAGI from source" msg_info "Creating Service" @@ -62,7 +85,15 @@ After=network.target Type=simple WorkingDirectory=/opt/localagi EnvironmentFile=/opt/localagi/.env +User=localagi ExecStart=/usr/local/bin/localagi +NoNewPrivileges=true +PrivateTmp=true +ProtectSystem=full +ProtectHome=true +AmbientCapabilities= +StandardOutput=journal +StandardError=journal Restart=on-failure RestartSec=5 From 92e3192cb7714823c27164dc959f506bb5d0e097 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:41:55 -0500 Subject: [PATCH 056/101] feat: add user creation and systemd unit hardening for LocalAGI installation --- ct/localagi.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index 6be6bc58d..d1634ea02 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -58,6 +58,48 @@ function update_script() { CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" msg_ok "Updated LocalAGI" + # Ensure dedicated system user exists and ownership is correct + if ! id -u localagi >/dev/null 2>&1; then + msg_info "Creating system user 'localagi'" + useradd --system --no-create-home --shell /usr/sbin/nologin --home /opt/localagi localagi || \ + msg_warn "Failed to create 'localagi' user; continuing if it already exists" + fi + + msg_info "Setting ownership of /opt/localagi to localagi:localagi" + chown -R localagi:localagi /opt/localagi || msg_warn "Failed to chown /opt/localagi" + + # Ensure systemd unit has basic hardening; if not, rewrite it + if ! grep -q '^User=localagi' /etc/systemd/system/localagi.service 2>/dev/null || \ + ! grep -q '^NoNewPrivileges=true' /etc/systemd/system/localagi.service 2>/dev/null; then + msg_info "Installing hardened systemd unit for LocalAGI" + cat </etc/systemd/system/localagi.service +[Unit] +Description=LocalAGI Service +After=network.target + +[Service] +Type=simple +WorkingDirectory=/opt/localagi +EnvironmentFile=/opt/localagi/.env +User=localagi +ExecStart=/usr/local/bin/localagi +NoNewPrivileges=true +PrivateTmp=true +ProtectSystem=full +ProtectHome=true +AmbientCapabilities= +StandardOutput=journal +StandardError=journal +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF + systemctl daemon-reload + msg_ok "Installed systemd unit" + fi + if [[ "${env_backup_valid:-0}" == "1" && -n "${env_backup:-}" && -s "$env_backup" ]]; then msg_info "Restoring Environment" cp "$env_backup" /opt/localagi/.env From a6f13f3e30bf7c8dc639f885217d6b01596eaa06 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:43:45 -0500 Subject: [PATCH 057/101] feat: implement systemd drop-in override for LocalAGI service hardening --- ct/localagi.sh | 34 +++++++++++++++------------------- install/localagi-install.sh | 34 ++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index d1634ea02..65750dbea 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -68,21 +68,14 @@ function update_script() { msg_info "Setting ownership of /opt/localagi to localagi:localagi" chown -R localagi:localagi /opt/localagi || msg_warn "Failed to chown /opt/localagi" - # Ensure systemd unit has basic hardening; if not, rewrite it - if ! grep -q '^User=localagi' /etc/systemd/system/localagi.service 2>/dev/null || \ - ! grep -q '^NoNewPrivileges=true' /etc/systemd/system/localagi.service 2>/dev/null; then - msg_info "Installing hardened systemd unit for LocalAGI" - cat </etc/systemd/system/localagi.service -[Unit] -Description=LocalAGI Service -After=network.target - + # Ensure systemd unit has basic hardening via drop-in override + mkdir -p /etc/systemd/system/localagi.service.d + override_file=/etc/systemd/system/localagi.service.d/override.conf + if [[ ! -f "$override_file" ]]; then + msg_info "Creating systemd drop-in override for LocalAGI" + cat <"$override_file" [Service] -Type=simple -WorkingDirectory=/opt/localagi -EnvironmentFile=/opt/localagi/.env User=localagi -ExecStart=/usr/local/bin/localagi NoNewPrivileges=true PrivateTmp=true ProtectSystem=full @@ -90,14 +83,17 @@ ProtectHome=true AmbientCapabilities= StandardOutput=journal StandardError=journal -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target EOF systemctl daemon-reload - msg_ok "Installed systemd unit" + msg_ok "Installed systemd drop-in" + else + msg_info "Systemd drop-in exists; ensuring required directives" + for d in "User=localagi" "NoNewPrivileges=true" "PrivateTmp=true" "ProtectSystem=full" "ProtectHome=true" "AmbientCapabilities=" "StandardOutput=journal" "StandardError=journal"; do + if ! grep -q "^${d}" "$override_file" 2>/dev/null; then + echo "$d" >>"$override_file" + fi + done + systemctl daemon-reload fi if [[ "${env_backup_valid:-0}" == "1" && -n "${env_backup:-}" && -s "$env_backup" ]]; then diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 2d914f1c9..797cd522d 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -76,17 +76,13 @@ chmod 755 /usr/local/bin/localagi || msg_warn "Failed to chmod /usr/local/bin/lo msg_ok "Built LocalAGI from source" msg_info "Creating Service" -cat </etc/systemd/system/localagi.service -[Unit] -Description=LocalAGI Service -After=network.target - +mkdir -p /etc/systemd/system/localagi.service.d +override_file=/etc/systemd/system/localagi.service.d/override.conf +if [[ ! -f "$override_file" ]]; then + msg_info "Creating systemd drop-in override for LocalAGI" + cat <"$override_file" [Service] -Type=simple -WorkingDirectory=/opt/localagi -EnvironmentFile=/opt/localagi/.env User=localagi -ExecStart=/usr/local/bin/localagi NoNewPrivileges=true PrivateTmp=true ProtectSystem=full @@ -94,16 +90,22 @@ ProtectHome=true AmbientCapabilities= StandardOutput=journal StandardError=journal -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target EOF -systemctl daemon-reload + systemctl daemon-reload +else + msg_info "Systemd drop-in exists; ensuring required directives" + # Ensure required directives present; add if missing + for d in "User=localagi" "NoNewPrivileges=true" "PrivateTmp=true" "ProtectSystem=full" "ProtectHome=true" "AmbientCapabilities=" "StandardOutput=journal" "StandardError=journal"; do + if ! grep -q "^${d}" "$override_file" 2>/dev/null; then + echo "$d" >>"$override_file" + fi + done + systemctl daemon-reload +fi + LOCALAGI_SERVICE_NEEDS_RECOVERY=1 systemctl enable -q --now localagi -msg_ok "Created Service" +msg_ok "Created Service (drop-in override)" if ! systemctl is-active -q localagi; then msg_error "Failed to start LocalAGI service" From 05ea89e3d05571ea1fc84d62c9b316bd0c281aa5 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:45:04 -0500 Subject: [PATCH 058/101] feat: add health check and release tag recording for LocalAGI installation and updates --- ct/localagi.sh | 32 ++++++++++++++++++++++++++++++++ install/localagi-install.sh | 10 ++++++++++ 2 files changed, 42 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index 65750dbea..a69f54bfc 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -21,6 +21,23 @@ variables color catch_errors +function health_check() { + header_info + + if [[ ! -d /opt/localagi ]]; then + msg_error "LocalAGI not found at /opt/localagi" + return 1 + fi + + if ! systemctl is-active --quiet localagi; then + msg_error "LocalAGI service not running" + return 1 + fi + + msg_ok "Health check passed: LocalAGI installed and service running" + return 0 +} + function update_script() { header_info check_container_storage @@ -58,6 +75,16 @@ function update_script() { CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" msg_ok "Updated LocalAGI" + # Record installed release tag for update checks + msg_info "Recording installed LocalAGI release tag" + release_tag=$(curl -fsSL "https://api.github.com/repos/mudler/LocalAGI/releases/latest" | grep -E '"tag_name"' | head -n1 | sed -E 's/[^\"]*"([^"]+)".*/\1/' 2>/dev/null || true) + if [[ -n "$release_tag" ]]; then + echo "$release_tag" >/opt/localagi/LOCALAGI_VERSION.txt 2>/dev/null || msg_warn "Failed to write version file" + msg_ok "Recorded release: $release_tag" + else + msg_warn "Could not determine release tag for LocalAGI" + fi + # Ensure dedicated system user exists and ownership is correct if ! id -u localagi >/dev/null 2>&1; then msg_info "Creating system user 'localagi'" @@ -144,6 +171,11 @@ EOF } msg_ok "Started LocalAGI (external-llm)" + # Run health check after start + health_check || { + msg_warn "Health check failed after update; check service logs" + } + msg_ok "Updated successfully!" fi exit diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 797cd522d..e5998e5ce 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -33,6 +33,16 @@ if [[ ! -d /opt/localagi/webui/react-ui ]]; then exit 1 fi +# Record installed release tag for update checks +msg_info "Recording installed LocalAGI release tag" +release_tag=$(curl -fsSL "https://api.github.com/repos/mudler/LocalAGI/releases/latest" | grep -E '"tag_name"' | head -n1 | sed -E 's/[^\"]*"([^"]+)".*/\1/' 2>/dev/null || true) +if [[ -n "$release_tag" ]]; then + echo "$release_tag" >/opt/localagi/LOCALAGI_VERSION.txt 2>/dev/null || msg_warn "Failed to write version file" + msg_ok "Recorded release: $release_tag" +else + msg_warn "Could not determine release tag for LocalAGI" +fi + mkdir -p /opt/localagi/pool msg_info "Configuring LocalAGI" From 3bbc5a933b4213c3a26122bbad612d79f3749645 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:45:55 -0500 Subject: [PATCH 059/101] fix: update source URL for build functions in localagi.sh --- ct/localagi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index a69f54bfc..5cda7a9f4 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/BillyOutlast/ProxmoxVED/LocalAGI/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: BillyOutlast From b844eab504efadfc773756216b96c25951e652a1 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:50:35 -0500 Subject: [PATCH 060/101] feat: enhance LocalAGI installation and update process with version checks and improved Bun installation --- ct/localagi.sh | 61 ++++++++++++++++++++---------- frontend/public/json/localagi.json | 2 +- install/localagi-install.sh | 49 +++++++++++++++--------- 3 files changed, 74 insertions(+), 38 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 5cda7a9f4..eb3917add 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -71,38 +71,47 @@ function update_script() { msg_warn "Skipping environment backup: /opt/localagi/.env missing or empty" fi - msg_info "Updating LocalAGI" - CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" - msg_ok "Updated LocalAGI" + msg_info "Checking latest LocalAGI release" + # Determine installed version (if recorded) + installed_version="" + if [[ -f /opt/localagi/LOCALAGI_VERSION.txt ]]; then + installed_version=$(grep -E '^Version:' /opt/localagi/LOCALAGI_VERSION.txt 2>/dev/null | head -n1 | awk -F': ' '{print $2}') || installed_version="" + fi + + # Fetch latest tag from GitHub + latest_tag=$(curl -fsSL "https://api.github.com/repos/mudler/LocalAGI/releases/latest" | grep -E '"tag_name"' | head -n1 | sed -E 's/[^\"]*"([^"]+)".*/\1/' 2>/dev/null || true) + + if [[ -n "$installed_version" && -n "$latest_tag" && "$installed_version" == "$latest_tag" ]]; then + msg_ok "LocalAGI is already up-to-date (version: $installed_version). Skipping update." + else + msg_info "Updating LocalAGI to ${latest_tag:-latest}" + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" + msg_ok "Updated LocalAGI" + fi - # Record installed release tag for update checks msg_info "Recording installed LocalAGI release tag" release_tag=$(curl -fsSL "https://api.github.com/repos/mudler/LocalAGI/releases/latest" | grep -E '"tag_name"' | head -n1 | sed -E 's/[^\"]*"([^"]+)".*/\1/' 2>/dev/null || true) if [[ -n "$release_tag" ]]; then - echo "$release_tag" >/opt/localagi/LOCALAGI_VERSION.txt 2>/dev/null || msg_warn "Failed to write version file" + cat >/opt/localagi/LOCALAGI_VERSION.txt </dev/null 2>&1; then - msg_info "Creating system user 'localagi'" - useradd --system --no-create-home --shell /usr/sbin/nologin --home /opt/localagi localagi || \ - msg_warn "Failed to create 'localagi' user; continuing if it already exists" - fi + # Running service as root per project guidelines (AI.md) - msg_info "Setting ownership of /opt/localagi to localagi:localagi" - chown -R localagi:localagi /opt/localagi || msg_warn "Failed to chown /opt/localagi" - - # Ensure systemd unit has basic hardening via drop-in override mkdir -p /etc/systemd/system/localagi.service.d override_file=/etc/systemd/system/localagi.service.d/override.conf if [[ ! -f "$override_file" ]]; then msg_info "Creating systemd drop-in override for LocalAGI" - cat <"$override_file" + cat <<'EOF' >"$override_file" [Service] -User=localagi +User=root NoNewPrivileges=true PrivateTmp=true ProtectSystem=full @@ -115,7 +124,7 @@ EOF msg_ok "Installed systemd drop-in" else msg_info "Systemd drop-in exists; ensuring required directives" - for d in "User=localagi" "NoNewPrivileges=true" "PrivateTmp=true" "ProtectSystem=full" "ProtectHome=true" "AmbientCapabilities=" "StandardOutput=journal" "StandardError=journal"; do + for d in "User=root" "NoNewPrivileges=true" "PrivateTmp=true" "ProtectSystem=full" "ProtectHome=true" "AmbientCapabilities=" "StandardOutput=journal" "StandardError=journal"; do if ! grep -q "^${d}" "$override_file" 2>/dev/null; then echo "$d" >>"$override_file" fi @@ -148,8 +157,20 @@ EOF NODE_VERSION="24" setup_nodejs setup_go msg_info "Installing Bun" - $STD npm install -g bun - msg_ok "Installed Bun" + if ! command -v bun >/dev/null 2>&1; then + if curl -fsSL https://bun.sh/install | bash -s -- --no-chmod >/dev/null 2>&1; then + msg_ok "Installed Bun (official installer)" + if [[ -x /root/.bun/bin/bun ]]; then + ln -sf /root/.bun/bin/bun /usr/local/bin/bun || msg_warn "Failed to symlink bun to /usr/local/bin" + fi + else + msg_warn "Official Bun installer failed, falling back to npm" + $STD npm install -g bun || { msg_error "Failed to install Bun"; exit 1; } + msg_ok "Installed Bun (npm)" + fi + else + msg_ok "Bun already installed" + fi msg_info "Building LocalAGI from source" ( diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index e01439467..e91932957 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -50,7 +50,7 @@ } , { - "text": "The service runs as a dedicated system user `localagi` and the unit includes basic hardening (NoNewPrivileges, PrivateTmp, ProtectSystem).", + "text": "The service runs as `root` per project guidelines; the unit includes basic hardening (NoNewPrivileges, PrivateTmp, ProtectSystem).", "type": "info" } ] diff --git a/install/localagi-install.sh b/install/localagi-install.sh index e5998e5ce..cadd73667 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -23,8 +23,21 @@ NODE_VERSION="24" setup_nodejs setup_go msg_info "Installing Bun" -$STD npm install -g bun -msg_ok "Installed Bun" +if ! command -v bun >/dev/null 2>&1; then + msg_info "Installing Bun (official installer)" + if curl -fsSL https://bun.sh/install | bash -s -- --no-chmod >/dev/null 2>&1; then + msg_ok "Installed Bun (official installer)" + if [[ -x /root/.bun/bin/bun ]]; then + ln -sf /root/.bun/bin/bun /usr/local/bin/bun || msg_warn "Failed to symlink bun to /usr/local/bin" + fi + else + msg_warn "Official Bun installer failed, falling back to npm" + $STD npm install -g bun || { msg_error "Failed to install Bun"; exit 1; } + msg_ok "Installed Bun (npm)" + fi +else + msg_ok "Bun already installed" +fi fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" @@ -33,11 +46,16 @@ if [[ ! -d /opt/localagi/webui/react-ui ]]; then exit 1 fi -# Record installed release tag for update checks +# Record installed release tag for update checks (full metadata) msg_info "Recording installed LocalAGI release tag" release_tag=$(curl -fsSL "https://api.github.com/repos/mudler/LocalAGI/releases/latest" | grep -E '"tag_name"' | head -n1 | sed -E 's/[^\"]*"([^"]+)".*/\1/' 2>/dev/null || true) if [[ -n "$release_tag" ]]; then - echo "$release_tag" >/opt/localagi/LOCALAGI_VERSION.txt 2>/dev/null || msg_warn "Failed to write version file" + cat >/opt/localagi/LOCALAGI_VERSION.txt </opt/localagi/.env +cat <<'EOF' >/opt/localagi/.env LOCALAGI_MODEL=gemma-3-4b-it-qat LOCALAGI_MULTIMODAL_MODEL=moondream2-20250414 LOCALAGI_IMAGE_MODEL=sd-1.5-ggml @@ -60,15 +78,7 @@ msg_ok "Configured LocalAGI" msg_info "Building LocalAGI from source" -# Create dedicated system user to run the service -if ! id -u localagi >/dev/null 2>&1; then - msg_info "Creating system user 'localagi'" - useradd --system --no-create-home --shell /usr/sbin/nologin --home /opt/localagi localagi || \ - msg_warn "Failed to create 'localagi' user; continuing if it already exists" -fi - -# Ensure ownership and perms -chown -R localagi:localagi /opt/localagi || msg_warn "Failed to chown /opt/localagi" +# Running service as root per project guidelines (AI.md) cd /opt/localagi/webui/react-ui || { msg_error "Missing webui/react-ui directory"; exit 1; } @@ -90,9 +100,9 @@ mkdir -p /etc/systemd/system/localagi.service.d override_file=/etc/systemd/system/localagi.service.d/override.conf if [[ ! -f "$override_file" ]]; then msg_info "Creating systemd drop-in override for LocalAGI" - cat <"$override_file" + cat <<'EOF' >"$override_file" [Service] -User=localagi +User=root NoNewPrivileges=true PrivateTmp=true ProtectSystem=full @@ -105,7 +115,7 @@ EOF else msg_info "Systemd drop-in exists; ensuring required directives" # Ensure required directives present; add if missing - for d in "User=localagi" "NoNewPrivileges=true" "PrivateTmp=true" "ProtectSystem=full" "ProtectHome=true" "AmbientCapabilities=" "StandardOutput=journal" "StandardError=journal"; do + for d in "User=root" "NoNewPrivileges=true" "PrivateTmp=true" "ProtectSystem=full" "ProtectHome=true" "AmbientCapabilities=" "StandardOutput=journal" "StandardError=journal"; do if ! grep -q "^${d}" "$override_file" 2>/dev/null; then echo "$d" >>"$override_file" fi @@ -122,6 +132,11 @@ if ! systemctl is-active -q localagi; then exit 1 fi +msg_info "Cleaning up package cache" +$STD apt-get -y autoremove || msg_warn "apt autoremove failed" +$STD apt-get -y autoclean || msg_warn "apt autoclean failed" +msg_ok "Cleaned package cache" + motd_ssh customize cleanup_lxc From 8a3d6f3a2b11b910e1654cc5b89834981308c66b Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:58:03 -0500 Subject: [PATCH 061/101] fix: update source URL and improve Bun installation in LocalAGI scripts --- ct/localagi.sh | 208 +++++++++--------------------------- install/localagi-install.sh | 99 ++++++----------- 2 files changed, 84 insertions(+), 223 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index eb3917add..2fd9f0ef1 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/BillyOutlast/ProxmoxVED/LocalAGI/misc/build.func) +source <(curl -sSL https://raw.githubusercontent.com/asylumexp/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: BillyOutlast @@ -7,7 +7,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/BillyOutlast/ProxmoxVED/Lo # Source: https://github.com/mudler/LocalAGI APP="LocalAGI" -var_tags="${var_tags:-ai;agents}" +var_tags="${var_tags:-ai,agents}" var_cpu="${var_cpu:-2}" var_ram="${var_ram:-4096}" var_disk="${var_disk:-20}" @@ -23,17 +23,14 @@ catch_errors function health_check() { header_info - if [[ ! -d /opt/localagi ]]; then msg_error "LocalAGI not found at /opt/localagi" return 1 fi - if ! systemctl is-active --quiet localagi; then msg_error "LocalAGI service not running" return 1 fi - msg_ok "Health check passed: LocalAGI installed and service running" return 0 } @@ -43,162 +40,61 @@ function update_script() { check_container_storage check_container_resources - if [[ ! -d /opt/localagi || ! -f /etc/systemd/system/localagi.service ]]; then + if [[ ! -d /opt/localagi || ! -f /opt/localagi/LOCALAGI_VERSION.txt ]]; then msg_error "No ${APP} Installation Found!" exit 1 fi - if check_for_gh_release "localagi" "mudler/LocalAGI"; then - msg_info "Stopping LocalAGI Service" - systemctl stop localagi - msg_ok "Stopped LocalAGI Service" - - msg_info "Backing up Environment" - local env_backup - local env_backup_valid=0 - if [[ -s /opt/localagi/.env ]]; then - env_backup="$(mktemp /tmp/localagi.env.XXXXXX)" - chmod 600 "$env_backup" - if cp /opt/localagi/.env "$env_backup" 2>/dev/null && [[ -s "$env_backup" ]]; then - env_backup_valid=1 - msg_ok "Backed up Environment" - else - rm -f "$env_backup" - env_backup="" - msg_warn "Failed to create valid environment backup" - fi - else - msg_warn "Skipping environment backup: /opt/localagi/.env missing or empty" - fi - - msg_info "Checking latest LocalAGI release" - # Determine installed version (if recorded) - installed_version="" - if [[ -f /opt/localagi/LOCALAGI_VERSION.txt ]]; then - installed_version=$(grep -E '^Version:' /opt/localagi/LOCALAGI_VERSION.txt 2>/dev/null | head -n1 | awk -F': ' '{print $2}') || installed_version="" - fi - - # Fetch latest tag from GitHub - latest_tag=$(curl -fsSL "https://api.github.com/repos/mudler/LocalAGI/releases/latest" | grep -E '"tag_name"' | head -n1 | sed -E 's/[^\"]*"([^"]+)".*/\1/' 2>/dev/null || true) - - if [[ -n "$installed_version" && -n "$latest_tag" && "$installed_version" == "$latest_tag" ]]; then - msg_ok "LocalAGI is already up-to-date (version: $installed_version). Skipping update." - else - msg_info "Updating LocalAGI to ${latest_tag:-latest}" - CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" - msg_ok "Updated LocalAGI" - fi - - msg_info "Recording installed LocalAGI release tag" - release_tag=$(curl -fsSL "https://api.github.com/repos/mudler/LocalAGI/releases/latest" | grep -E '"tag_name"' | head -n1 | sed -E 's/[^\"]*"([^"]+)".*/\1/' 2>/dev/null || true) - if [[ -n "$release_tag" ]]; then - cat >/opt/localagi/LOCALAGI_VERSION.txt <"$override_file" -[Service] -User=root -NoNewPrivileges=true -PrivateTmp=true -ProtectSystem=full -ProtectHome=true -AmbientCapabilities= -StandardOutput=journal -StandardError=journal -EOF - systemctl daemon-reload - msg_ok "Installed systemd drop-in" - else - msg_info "Systemd drop-in exists; ensuring required directives" - for d in "User=root" "NoNewPrivileges=true" "PrivateTmp=true" "ProtectSystem=full" "ProtectHome=true" "AmbientCapabilities=" "StandardOutput=journal" "StandardError=journal"; do - if ! grep -q "^${d}" "$override_file" 2>/dev/null; then - echo "$d" >>"$override_file" - fi - done - systemctl daemon-reload - fi - - if [[ "${env_backup_valid:-0}" == "1" && -n "${env_backup:-}" && -s "$env_backup" ]]; then - msg_info "Restoring Environment" - cp "$env_backup" /opt/localagi/.env - rm -f "$env_backup" - msg_ok "Restored Environment" - fi - - msg_ok "Backend mode: external-llm" - if [[ ! -f /opt/localagi/.env ]]; then - msg_warn "Missing /opt/localagi/.env. Recreate by running install script again." - exit 1 - fi - - if grep -q '^LOCALAGI_LLM_API_URL=http://127.0.0.1:8081$' /opt/localagi/.env; then - if grep -q '^LOCALAGI_LLM_API_URL=' /opt/localagi/.env; then - sed -i 's|^LOCALAGI_LLM_API_URL=.*|LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1|' /opt/localagi/.env - else - echo "LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1" >>/opt/localagi/.env - fi - msg_warn "Migrated LOCALAGI_LLM_API_URL from 127.0.0.1:8081 to 127.0.0.1:11434/v1" - fi - - NODE_VERSION="24" setup_nodejs - setup_go - msg_info "Installing Bun" - if ! command -v bun >/dev/null 2>&1; then - if curl -fsSL https://bun.sh/install | bash -s -- --no-chmod >/dev/null 2>&1; then - msg_ok "Installed Bun (official installer)" - if [[ -x /root/.bun/bin/bun ]]; then - ln -sf /root/.bun/bin/bun /usr/local/bin/bun || msg_warn "Failed to symlink bun to /usr/local/bin" - fi - else - msg_warn "Official Bun installer failed, falling back to npm" - $STD npm install -g bun || { msg_error "Failed to install Bun"; exit 1; } - msg_ok "Installed Bun (npm)" - fi - else - msg_ok "Bun already installed" - fi - - msg_info "Building LocalAGI from source" - ( - cd /opt/localagi/webui/react-ui && - $STD bun install && - $STD bun run build && - cd /opt/localagi && - $STD go build -o /usr/local/bin/localagi - ) || { - msg_error "Failed to build LocalAGI from source" - exit 1 - } - msg_ok "Built LocalAGI from source" - - msg_info "Starting LocalAGI Service" - systemctl restart localagi || { - msg_error "Failed to start LocalAGI service" - exit 1 - } - msg_ok "Started LocalAGI (external-llm)" - - # Run health check after start - health_check || { - msg_warn "Health check failed after update; check service logs" - } - - msg_ok "Updated successfully!" + if ! check_for_gh_release "localagi" "mudler/LocalAGI"; then + exit 0 fi + + msg_info "Stopping LocalAGI Service" + systemctl stop localagi + msg_ok "Stopped LocalAGI Service" + + msg_info "Backing up Environment" + local env_backup_file + env_backup_file=$(mktemp) + if cp /opt/localagi/.env "$env_backup_file"; then + msg_ok "Backed up Environment" + else + msg_warn "Failed to back up environment file" + fi + + msg_info "Updating LocalAGI" + cd /opt + rm -rf localagi + fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" + msg_ok "Updated LocalAGI" + + msg_info "Restoring Environment" + if [[ -f "$env_backup_file" ]]; then + cp "$env_backup_file" /opt/localagi/.env + rm -f "$env_backup_file" + msg_ok "Restored Environment" + fi + + msg_info "Building LocalAGI from source" + ( + cd /opt/localagi/webui/react-ui && + bun install && + bun run build && + cd /opt/localagi && + go build -o /usr/local/bin/localagi + ) || { + msg_error "Failed to build LocalAGI from source" + exit 1 + } + msg_ok "Built LocalAGI from source" + + msg_info "Starting LocalAGI Service" + systemctl restart localagi + msg_ok "Started LocalAGI" + + health_check + + msg_ok "Updated Successfully" exit } diff --git a/install/localagi-install.sh b/install/localagi-install.sh index cadd73667..f76dd2b34 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -14,7 +14,6 @@ setting_up_container network_check update_os - msg_info "Installing Dependencies" $STD apt install -y build-essential msg_ok "Installed Dependencies" @@ -24,15 +23,14 @@ setup_go msg_info "Installing Bun" if ! command -v bun >/dev/null 2>&1; then - msg_info "Installing Bun (official installer)" if curl -fsSL https://bun.sh/install | bash -s -- --no-chmod >/dev/null 2>&1; then msg_ok "Installed Bun (official installer)" if [[ -x /root/.bun/bin/bun ]]; then - ln -sf /root/.bun/bin/bun /usr/local/bin/bun || msg_warn "Failed to symlink bun to /usr/local/bin" + ln -sf /root/.bun/bin/bun /usr/local/bin/bun fi else msg_warn "Official Bun installer failed, falling back to npm" - $STD npm install -g bun || { msg_error "Failed to install Bun"; exit 1; } + $STD npm install -g bun msg_ok "Installed Bun (npm)" fi else @@ -41,29 +39,11 @@ fi fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" -if [[ ! -d /opt/localagi/webui/react-ui ]]; then - msg_error "Unexpected release layout: /opt/localagi/webui/react-ui not found" - exit 1 -fi - -# Record installed release tag for update checks (full metadata) -msg_info "Recording installed LocalAGI release tag" -release_tag=$(curl -fsSL "https://api.github.com/repos/mudler/LocalAGI/releases/latest" | grep -E '"tag_name"' | head -n1 | sed -E 's/[^\"]*"([^"]+)".*/\1/' 2>/dev/null || true) -if [[ -n "$release_tag" ]]; then - cat >/opt/localagi/LOCALAGI_VERSION.txt </opt/localagi/.env LOCALAGI_MODEL=gemma-3-4b-it-qat LOCALAGI_MULTIMODAL_MODEL=moondream2-20250414 @@ -77,30 +57,32 @@ chmod 600 /opt/localagi/.env msg_ok "Configured LocalAGI" msg_info "Building LocalAGI from source" - -# Running service as root per project guidelines (AI.md) - -cd /opt/localagi/webui/react-ui || { msg_error "Missing webui/react-ui directory"; exit 1; } - -msg_info "Running bun install" -$STD bun install || { msg_error "bun install failed"; exit 1; } - -msg_info "Building web UI" -$STD bun run build || { msg_error "bun build failed"; exit 1; } - -cd /opt/localagi || { msg_error "Missing /opt/localagi"; exit 1; } - -msg_info "Building Go binary" -$STD go build -o /usr/local/bin/localagi || { msg_error "go build failed"; exit 1; } -chmod 755 /usr/local/bin/localagi || msg_warn "Failed to chmod /usr/local/bin/localagi" +( + cd /opt/localagi/webui/react-ui && + bun install && + bun run build && + cd /opt/localagi && + go build -o /usr/local/bin/localagi +) || exit 1 msg_ok "Built LocalAGI from source" msg_info "Creating Service" +service_path="/etc/systemd/system/localagi.service" +cat <"$service_path" +[Unit] +Description=LocalAGI +After=network.target +[Service] +Type=simple +WorkingDirectory=/opt/localagi +ExecStart=/usr/local/bin/localagi +[Install] +WantedBy=multi-user.target +EOF + mkdir -p /etc/systemd/system/localagi.service.d override_file=/etc/systemd/system/localagi.service.d/override.conf -if [[ ! -f "$override_file" ]]; then - msg_info "Creating systemd drop-in override for LocalAGI" - cat <<'EOF' >"$override_file" +cat <<'EOF' >"$override_file" [Service] User=root NoNewPrivileges=true @@ -111,32 +93,15 @@ AmbientCapabilities= StandardOutput=journal StandardError=journal EOF - systemctl daemon-reload -else - msg_info "Systemd drop-in exists; ensuring required directives" - # Ensure required directives present; add if missing - for d in "User=root" "NoNewPrivileges=true" "PrivateTmp=true" "ProtectSystem=full" "ProtectHome=true" "AmbientCapabilities=" "StandardOutput=journal" "StandardError=journal"; do - if ! grep -q "^${d}" "$override_file" 2>/dev/null; then - echo "$d" >>"$override_file" - fi - done - systemctl daemon-reload -fi +systemctl daemon-reload +systemd-analyze verify localagi.service +msg_ok "Created Service" -LOCALAGI_SERVICE_NEEDS_RECOVERY=1 +msg_info "Starting LocalAGI Service" systemctl enable -q --now localagi -msg_ok "Created Service (drop-in override)" - -if ! systemctl is-active -q localagi; then - msg_error "Failed to start LocalAGI service" - exit 1 -fi - -msg_info "Cleaning up package cache" -$STD apt-get -y autoremove || msg_warn "apt autoremove failed" -$STD apt-get -y autoclean || msg_warn "apt autoclean failed" -msg_ok "Cleaned package cache" +msg_ok "Started LocalAGI Service" +cleanup motd_ssh customize cleanup_lxc From 7ece196cff339d82dd1a413e86ce1dc6402603d3 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:59:14 -0500 Subject: [PATCH 062/101] fix: refactor LocalAGI service configuration to use systemd drop-in override --- install/localagi-install.sh | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index f76dd2b34..97742a5cd 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -73,17 +73,6 @@ cat <"$service_path" Description=LocalAGI After=network.target [Service] -Type=simple -WorkingDirectory=/opt/localagi -ExecStart=/usr/local/bin/localagi -[Install] -WantedBy=multi-user.target -EOF - -mkdir -p /etc/systemd/system/localagi.service.d -override_file=/etc/systemd/system/localagi.service.d/override.conf -cat <<'EOF' >"$override_file" -[Service] User=root NoNewPrivileges=true PrivateTmp=true @@ -92,7 +81,13 @@ ProtectHome=true AmbientCapabilities= StandardOutput=journal StandardError=journal +Type=simple +WorkingDirectory=/opt/localagi +ExecStart=/usr/local/bin/localagi +[Install] +WantedBy=multi-user.target EOF + systemctl daemon-reload systemd-analyze verify localagi.service msg_ok "Created Service" From 9a74d59517cc1735b73957bfa777f2126418e37b Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:59:54 -0500 Subject: [PATCH 063/101] fix: simplify build process in localagi-install.sh by removing subshell --- install/localagi-install.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 97742a5cd..ac1ee08bf 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -57,13 +57,11 @@ chmod 600 /opt/localagi/.env msg_ok "Configured LocalAGI" msg_info "Building LocalAGI from source" -( - cd /opt/localagi/webui/react-ui && - bun install && - bun run build && - cd /opt/localagi && - go build -o /usr/local/bin/localagi -) || exit 1 +cd /opt/localagi/webui/react-ui && + bun install && + bun run build && + cd /opt/localagi && + go build -o /usr/local/bin/localagi msg_ok "Built LocalAGI from source" msg_info "Creating Service" From 50402cec026318a8c546a9924fb36ce2f66de0f3 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:01:01 -0500 Subject: [PATCH 064/101] fix: update source URL for build functions in localagi.sh --- ct/localagi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 2fd9f0ef1..aeb5a3e08 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -sSL https://raw.githubusercontent.com/asylumexp/ProxmoxVED/main/misc/build.func) +source <(curl -sSL https://raw.githubusercontent.com/BillyOutlast/ProxmoxVED/LocalAGI/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: BillyOutlast From 75578ab1737f50e2dd32540438dfc6f2d991600a Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:08:20 -0500 Subject: [PATCH 065/101] fix: remove unused health check function from localagi.sh --- ct/localagi.sh | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index aeb5a3e08..7266af322 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -21,20 +21,6 @@ variables color catch_errors -function health_check() { - header_info - if [[ ! -d /opt/localagi ]]; then - msg_error "LocalAGI not found at /opt/localagi" - return 1 - fi - if ! systemctl is-active --quiet localagi; then - msg_error "LocalAGI service not running" - return 1 - fi - msg_ok "Health check passed: LocalAGI installed and service running" - return 0 -} - function update_script() { header_info check_container_storage @@ -92,8 +78,6 @@ function update_script() { systemctl restart localagi msg_ok "Started LocalAGI" - health_check - msg_ok "Updated Successfully" exit } From 0ce45197f63e1fd5cbc2b559a6eac5bb7d05471a Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:11:08 -0500 Subject: [PATCH 066/101] fix: improve Bun installation process and ensure proper command execution --- install/localagi-install.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index ac1ee08bf..2e6979df9 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -23,12 +23,15 @@ setup_go msg_info "Installing Bun" if ! command -v bun >/dev/null 2>&1; then - if curl -fsSL https://bun.sh/install | bash -s -- --no-chmod >/dev/null 2>&1; then + # Download installer first so we don't pipe unknown remote code directly + if curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install && bash /tmp/bun-install.sh --no-chmod >/dev/null 2>&1; then + rm -f /tmp/bun-install.sh msg_ok "Installed Bun (official installer)" if [[ -x /root/.bun/bin/bun ]]; then ln -sf /root/.bun/bin/bun /usr/local/bin/bun fi else + rm -f /tmp/bun-install.sh || true msg_warn "Official Bun installer failed, falling back to npm" $STD npm install -g bun msg_ok "Installed Bun (npm)" @@ -58,10 +61,10 @@ msg_ok "Configured LocalAGI" msg_info "Building LocalAGI from source" cd /opt/localagi/webui/react-ui && - bun install && - bun run build && + $STD bun install && + $STD bun run build && cd /opt/localagi && - go build -o /usr/local/bin/localagi + $STD go build -o /usr/local/bin/localagi msg_ok "Built LocalAGI from source" msg_info "Creating Service" @@ -86,7 +89,6 @@ ExecStart=/usr/local/bin/localagi WantedBy=multi-user.target EOF -systemctl daemon-reload systemd-analyze verify localagi.service msg_ok "Created Service" @@ -94,7 +96,6 @@ msg_info "Starting LocalAGI Service" systemctl enable -q --now localagi msg_ok "Started LocalAGI Service" -cleanup motd_ssh customize cleanup_lxc From 8b441033bafc8d1cc553614054f244fe9f2e595b Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:13:25 -0500 Subject: [PATCH 067/101] fix: ensure proper command execution during LocalAGI source build process --- ct/localagi.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 7266af322..620942885 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -64,10 +64,10 @@ function update_script() { msg_info "Building LocalAGI from source" ( cd /opt/localagi/webui/react-ui && - bun install && - bun run build && + $STD bun install && + $STD bun run build && cd /opt/localagi && - go build -o /usr/local/bin/localagi + $STD go build -o /usr/local/bin/localagi ) || { msg_error "Failed to build LocalAGI from source" exit 1 From 4d4d5ae751f0b58ec783ac1ef3846b239d93082b Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:15:57 -0500 Subject: [PATCH 068/101] fix: streamline LocalAGI service creation by removing unnecessary options and verification step --- install/localagi-install.sh | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 2e6979df9..a00978713 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -68,31 +68,22 @@ cd /opt/localagi/webui/react-ui && msg_ok "Built LocalAGI from source" msg_info "Creating Service" -service_path="/etc/systemd/system/localagi.service" -cat <"$service_path" +cat </etc/systemd/system/localagi.service [Unit] Description=LocalAGI After=network.target + [Service] User=root -NoNewPrivileges=true -PrivateTmp=true -ProtectSystem=full -ProtectHome=true -AmbientCapabilities= -StandardOutput=journal -StandardError=journal Type=simple WorkingDirectory=/opt/localagi ExecStart=/usr/local/bin/localagi +Restart=on-failure + [Install] WantedBy=multi-user.target EOF -systemd-analyze verify localagi.service -msg_ok "Created Service" - -msg_info "Starting LocalAGI Service" systemctl enable -q --now localagi msg_ok "Started LocalAGI Service" From c42df7954223db5c58ae285721ba6fa2c7d1327d Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:17:55 -0500 Subject: [PATCH 069/101] fix: simplify Bun installation process by removing conditional checks and fallback to npm --- install/localagi-install.sh | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index a00978713..9816308f3 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -22,24 +22,12 @@ NODE_VERSION="24" setup_nodejs setup_go msg_info "Installing Bun" -if ! command -v bun >/dev/null 2>&1; then - # Download installer first so we don't pipe unknown remote code directly - if curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install && bash /tmp/bun-install.sh --no-chmod >/dev/null 2>&1; then - rm -f /tmp/bun-install.sh - msg_ok "Installed Bun (official installer)" - if [[ -x /root/.bun/bin/bun ]]; then - ln -sf /root/.bun/bin/bun /usr/local/bin/bun - fi - else - rm -f /tmp/bun-install.sh || true - msg_warn "Official Bun installer failed, falling back to npm" - $STD npm install -g bun - msg_ok "Installed Bun (npm)" - fi -else - msg_ok "Bun already installed" +curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install && bash /tmp/bun-install.sh --no-chmod >/dev/null 2>&1; then +rm -f /tmp/bun-install.sh +msg_ok "Installed Bun (official installer)" +if [[ -x /root/.bun/bin/bun ]]; then + ln -sf /root/.bun/bin/bun /usr/local/bin/bun fi - fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" msg_info "Recording installed version" From 6a721f0b6704565749b22f7f0a678ac711397955 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:25:31 -0500 Subject: [PATCH 070/101] fix: update script source URL to use community-scripts repository --- ct/localagi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 620942885..d540e57f1 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -sSL https://raw.githubusercontent.com/BillyOutlast/ProxmoxVED/LocalAGI/misc/build.func) +source <(curl -sSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: BillyOutlast From 2352877bae873d6aad0a084c79cadff7b81e0c65 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:37:30 -0500 Subject: [PATCH 071/101] fix: correct syntax error in Bun installation command --- install/localagi-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 9816308f3..7809f8dd7 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -22,7 +22,7 @@ NODE_VERSION="24" setup_nodejs setup_go msg_info "Installing Bun" -curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install && bash /tmp/bun-install.sh --no-chmod >/dev/null 2>&1; then +curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install && bash /tmp/bun-install.sh --no-chmod >/dev/null 2>&1 rm -f /tmp/bun-install.sh msg_ok "Installed Bun (official installer)" if [[ -x /root/.bun/bin/bun ]]; then From 21f82e39bbc077834004cce78959cf8cabe3a237 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:41:15 -0500 Subject: [PATCH 072/101] fix: separate Bun installation command for better error handling --- install/localagi-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 7809f8dd7..80f0410af 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -22,7 +22,8 @@ NODE_VERSION="24" setup_nodejs setup_go msg_info "Installing Bun" -curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install && bash /tmp/bun-install.sh --no-chmod >/dev/null 2>&1 +curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install +bash /tmp/bun-install.sh --no-chmod rm -f /tmp/bun-install.sh msg_ok "Installed Bun (official installer)" if [[ -x /root/.bun/bin/bun ]]; then From 3ec7fb917e19c4987311ec1ae6baf37233bd95b4 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:49:02 -0500 Subject: [PATCH 073/101] fix: update Bun installation command to ensure proper execution --- install/localagi-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 80f0410af..e25581b0b 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -23,7 +23,8 @@ setup_go msg_info "Installing Bun" curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install -bash /tmp/bun-install.sh --no-chmod +chmod +x /tmp/bun-install.sh +bash /tmp/bun-install.sh rm -f /tmp/bun-install.sh msg_ok "Installed Bun (official installer)" if [[ -x /root/.bun/bin/bun ]]; then From be5ed7d43fa4059f54e389c6a249acd0946303a2 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:53:26 -0500 Subject: [PATCH 074/101] fix: remove version recording for installed LocalAGI --- install/localagi-install.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index e25581b0b..b63214984 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -32,10 +32,6 @@ if [[ -x /root/.bun/bin/bun ]]; then fi fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" -msg_info "Recording installed version" -record_gh_release_version "localagi" "mudler/LocalAGI" -msg_ok "Recorded installed version" - mkdir -p /opt/localagi/pool cat <<'EOF' >/opt/localagi/.env LOCALAGI_MODEL=gemma-3-4b-it-qat From 57b20c70259357cfba6b54be5888437ec8891541 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:54:02 -0500 Subject: [PATCH 075/101] fix: remove installation checks from update_script function --- ct/localagi.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index d540e57f1..843f042cf 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -26,15 +26,6 @@ function update_script() { check_container_storage check_container_resources - if [[ ! -d /opt/localagi || ! -f /opt/localagi/LOCALAGI_VERSION.txt ]]; then - msg_error "No ${APP} Installation Found!" - exit 1 - fi - - if ! check_for_gh_release "localagi" "mudler/LocalAGI"; then - exit 0 - fi - msg_info "Stopping LocalAGI Service" systemctl stop localagi msg_ok "Stopped LocalAGI Service" From 6f84e271ab73b32bfc43f2177cc52d31ad672775 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:59:18 -0500 Subject: [PATCH 076/101] fix: add EnvironmentFile directive to LocalAGI service --- install/localagi-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index b63214984..383cedb17 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -62,6 +62,8 @@ After=network.target [Service] User=root Type=simple +EnvironmentFile=/opt/localagi/.env + WorkingDirectory=/opt/localagi ExecStart=/usr/local/bin/localagi Restart=on-failure From a0282db2dde110c34dcdb2ebdf81f647b2addfa8 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 21:59:51 -0500 Subject: [PATCH 077/101] fix: suppress output during Bun installation for cleaner logs --- install/localagi-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 383cedb17..6c533ef2a 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -24,7 +24,7 @@ setup_go msg_info "Installing Bun" curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install chmod +x /tmp/bun-install.sh -bash /tmp/bun-install.sh +bash /tmp/bun-install.sh > /dev/null 2>&1 rm -f /tmp/bun-install.sh msg_ok "Installed Bun (official installer)" if [[ -x /root/.bun/bin/bun ]]; then From 5354ce8b04e01cd2ea757c2cc0fd8dca433c2ce3 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 22:13:04 -0500 Subject: [PATCH 078/101] fix: improve environment backup and restore process in update_script function --- ct/localagi.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 843f042cf..69e4501a4 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -32,11 +32,19 @@ function update_script() { msg_info "Backing up Environment" local env_backup_file - env_backup_file=$(mktemp) - if cp /opt/localagi/.env "$env_backup_file"; then - msg_ok "Backed up Environment" + env_backup_file="" + if [[ -f /opt/localagi/.env ]]; then + local tmp + tmp=$(mktemp) || tmp="" + if [[ -n "$tmp" ]] && cp /opt/localagi/.env "$tmp"; then + env_backup_file="$tmp" + msg_ok "Backed up Environment to ${env_backup_file}" + else + [[ -n "$tmp" ]] && rm -f "$tmp" + msg_warn "Failed to back up environment file" + fi else - msg_warn "Failed to back up environment file" + msg_warn "No /opt/localagi/.env to back up" fi msg_info "Updating LocalAGI" @@ -46,10 +54,10 @@ function update_script() { msg_ok "Updated LocalAGI" msg_info "Restoring Environment" - if [[ -f "$env_backup_file" ]]; then + if [[ -n "$env_backup_file" && -s "$env_backup_file" ]]; then cp "$env_backup_file" /opt/localagi/.env rm -f "$env_backup_file" - msg_ok "Restored Environment" + msg_ok "Restored Environment from ${env_backup_file}" fi msg_info "Building LocalAGI from source" From 76efff96bc6c670efea38efe52873b7cc8e90977 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 22:13:55 -0500 Subject: [PATCH 079/101] fix: remove outdated service information from localagi.json --- frontend/public/json/localagi.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frontend/public/json/localagi.json b/frontend/public/json/localagi.json index e91932957..44d6e18b1 100644 --- a/frontend/public/json/localagi.json +++ b/frontend/public/json/localagi.json @@ -48,10 +48,5 @@ "text": "To use an external Ollama host, edit `/opt/localagi/.env` and set `LOCALAGI_LLM_API_URL=http://:11434/v1`, then restart LocalAGI with `systemctl restart localagi`.", "type": "info" } - , - { - "text": "The service runs as `root` per project guidelines; the unit includes basic hardening (NoNewPrivileges, PrivateTmp, ProtectSystem).", - "type": "info" - } ] } From 6ac2534aff5132542b602460b50875bdae916897 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 22:16:07 -0500 Subject: [PATCH 080/101] fix: reload systemd daemon before restarting LocalAGI service --- ct/localagi.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index 69e4501a4..a3bbde0cd 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -74,6 +74,7 @@ function update_script() { msg_ok "Built LocalAGI from source" msg_info "Starting LocalAGI Service" + systemctl daemon-reload systemctl restart localagi msg_ok "Started LocalAGI" From a82d63cbd3e0c497b6ae00af24362a5d09c2dd3a Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 22:16:31 -0500 Subject: [PATCH 081/101] fix: replace restart with enable for LocalAGI service startup --- ct/localagi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index a3bbde0cd..1a74b3b64 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -75,7 +75,7 @@ function update_script() { msg_info "Starting LocalAGI Service" systemctl daemon-reload - systemctl restart localagi + systemctl enable -q --now localagi msg_ok "Started LocalAGI" msg_ok "Updated Successfully" From 33ba83a416cc450c33ce6bc149619dc8e451928b Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 13:36:48 -0500 Subject: [PATCH 082/101] fix: streamline update_script function by removing redundant messages and backup logic --- ct/localagi.sh | 47 ++++++++++------------------------------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 1a74b3b64..467d33265 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -26,59 +26,32 @@ function update_script() { check_container_storage check_container_resources - msg_info "Stopping LocalAGI Service" - systemctl stop localagi - msg_ok "Stopped LocalAGI Service" + $STD systemctl stop localagi - msg_info "Backing up Environment" - local env_backup_file - env_backup_file="" if [[ -f /opt/localagi/.env ]]; then - local tmp - tmp=$(mktemp) || tmp="" - if [[ -n "$tmp" ]] && cp /opt/localagi/.env "$tmp"; then - env_backup_file="$tmp" - msg_ok "Backed up Environment to ${env_backup_file}" - else - [[ -n "$tmp" ]] && rm -f "$tmp" - msg_warn "Failed to back up environment file" - fi - else - msg_warn "No /opt/localagi/.env to back up" + cp /opt/localagi/.env /opt/localagi/.env.backup fi - msg_info "Updating LocalAGI" cd /opt rm -rf localagi fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" - msg_ok "Updated LocalAGI" - msg_info "Restoring Environment" - if [[ -n "$env_backup_file" && -s "$env_backup_file" ]]; then - cp "$env_backup_file" /opt/localagi/.env - rm -f "$env_backup_file" - msg_ok "Restored Environment from ${env_backup_file}" + if [[ -f /opt/localagi/.env.backup ]]; then + cp /opt/localagi/.env.backup /opt/localagi/.env + rm -f /opt/localagi/.env.backup fi - msg_info "Building LocalAGI from source" - ( - cd /opt/localagi/webui/react-ui && - $STD bun install && - $STD bun run build && - cd /opt/localagi && - $STD go build -o /usr/local/bin/localagi - ) || { + cd /opt/localagi/webui/react-ui && + $STD bun install && + $STD bun run build && + cd /opt/localagi && + $STD go build -o /usr/local/bin/localagi || { msg_error "Failed to build LocalAGI from source" exit 1 } - msg_ok "Built LocalAGI from source" - msg_info "Starting LocalAGI Service" - systemctl daemon-reload systemctl enable -q --now localagi - msg_ok "Started LocalAGI" - msg_ok "Updated Successfully" exit } From 268d260fdc232dc91a81281598073b101074fe76 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 13:37:58 -0500 Subject: [PATCH 083/101] fix: simplify localagi-install.sh by removing redundant messages and streamlining installation steps --- install/localagi-install.sh | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 6c533ef2a..73a769129 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -14,22 +14,17 @@ setting_up_container network_check update_os -msg_info "Installing Dependencies" $STD apt install -y build-essential -msg_ok "Installed Dependencies" NODE_VERSION="24" setup_nodejs setup_go -msg_info "Installing Bun" -curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install -chmod +x /tmp/bun-install.sh -bash /tmp/bun-install.sh > /dev/null 2>&1 +$STD curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install +$STD chmod +x /tmp/bun-install.sh +$STD bash /tmp/bun-install.sh rm -f /tmp/bun-install.sh -msg_ok "Installed Bun (official installer)" -if [[ -x /root/.bun/bin/bun ]]; then - ln -sf /root/.bun/bin/bun /usr/local/bin/bun -fi +[[ -x /root/.bun/bin/bun ]] && ln -sf /root/.bun/bin/bun /usr/local/bin/bun + fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" mkdir -p /opt/localagi/pool @@ -43,18 +38,17 @@ LOCALAGI_TIMEOUT=5m LOCALAGI_ENABLE_CONVERSATIONS_LOGGING=false EOF chmod 600 /opt/localagi/.env -msg_ok "Configured LocalAGI" -msg_info "Building LocalAGI from source" cd /opt/localagi/webui/react-ui && $STD bun install && $STD bun run build && cd /opt/localagi && - $STD go build -o /usr/local/bin/localagi -msg_ok "Built LocalAGI from source" + $STD go build -o /usr/local/bin/localagi || { + msg_error "Failed to build LocalAGI from source" + exit 1 +} -msg_info "Creating Service" -cat </etc/systemd/system/localagi.service +cat <<'EOF' >/etc/systemd/system/localagi.service [Unit] Description=LocalAGI After=network.target @@ -73,7 +67,6 @@ WantedBy=multi-user.target EOF systemctl enable -q --now localagi -msg_ok "Started LocalAGI Service" motd_ssh customize From 23eb101dca6d9d2f6ed7779327207e394b4ac237 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:09:20 -0500 Subject: [PATCH 084/101] fix: streamline update_script function by removing unnecessary directory change and cleanup steps --- ct/localagi.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 467d33265..d16e2846f 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -32,9 +32,7 @@ function update_script() { cp /opt/localagi/.env /opt/localagi/.env.backup fi - cd /opt - rm -rf localagi - fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" if [[ -f /opt/localagi/.env.backup ]]; then cp /opt/localagi/.env.backup /opt/localagi/.env From dd1dd63a19b97b0b83f066dc20b63827b1f91050 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:12:00 -0500 Subject: [PATCH 085/101] fix: update backup file path in update_script function to use /tmp directory --- ct/localagi.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index d16e2846f..a51a4a2e8 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -29,14 +29,14 @@ function update_script() { $STD systemctl stop localagi if [[ -f /opt/localagi/.env ]]; then - cp /opt/localagi/.env /opt/localagi/.env.backup + cp /opt/localagi/.env /tmp/localagi.env.backup fi CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" - if [[ -f /opt/localagi/.env.backup ]]; then - cp /opt/localagi/.env.backup /opt/localagi/.env - rm -f /opt/localagi/.env.backup + if [[ -f /tmp/localagi.env.backup ]]; then + cp /tmp/localagi.env.backup /opt/localagi/.env + rm -f /tmp/localagi.env.backup fi cd /opt/localagi/webui/react-ui && From c0de2c92429f1324e3509cd71862de26cabdb3a0 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:14:06 -0500 Subject: [PATCH 086/101] fix: enhance update_script function with additional informational messages during backup and restore processes --- ct/localagi.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index a51a4a2e8..afdff53ae 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -29,12 +29,16 @@ function update_script() { $STD systemctl stop localagi if [[ -f /opt/localagi/.env ]]; then + msg_info "Backing up existing LocalAGI configuration" cp /opt/localagi/.env /tmp/localagi.env.backup fi + msg_info "Fetching and deploying latest LocalAGI release" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" + msg_info "Restoring LocalAGI configuration" if [[ -f /tmp/localagi.env.backup ]]; then + msg_info "Restoring LocalAGI configuration" cp /tmp/localagi.env.backup /opt/localagi/.env rm -f /tmp/localagi.env.backup fi From b64645a4f5339601d1de84abe925d210df7cfa29 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:16:24 -0500 Subject: [PATCH 087/101] fix: refactor update_script function to improve readability by separating commands onto individual lines --- ct/localagi.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index afdff53ae..e5cb86ba3 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -43,13 +43,13 @@ function update_script() { rm -f /tmp/localagi.env.backup fi - cd /opt/localagi/webui/react-ui && - $STD bun install && - $STD bun run build && - cd /opt/localagi && - $STD go build -o /usr/local/bin/localagi || { - msg_error "Failed to build LocalAGI from source" - exit 1 + cd /opt/localagi/webui/react-ui + $STD bun install + $STD bun run build + cd /opt/localagi + $STD go build -o /usr/local/bin/localagi || { + msg_error "Failed to build LocalAGI from source" + exit 1 } systemctl enable -q --now localagi From aeb49678d8f9fbd8d23b71841764dfd6be34793f Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:19:41 -0500 Subject: [PATCH 088/101] fix: add informational messages for stopping LocalAGI service in update_script function --- ct/localagi.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index e5cb86ba3..3d9550d85 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -26,7 +26,9 @@ function update_script() { check_container_storage check_container_resources + msg_info "Stopping LocalAGI service" $STD systemctl stop localagi + msg_ok "Stopped LocalAGI service" if [[ -f /opt/localagi/.env ]]; then msg_info "Backing up existing LocalAGI configuration" From efb6329952a9e1b5b52c4da28eda72c831fe97b6 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:22:16 -0500 Subject: [PATCH 089/101] fix: streamline update_script function by consolidating service stop and backup logic --- ct/localagi.sh | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 3d9550d85..d0c5fe716 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -25,33 +25,35 @@ function update_script() { header_info check_container_storage check_container_resources + if check_for_gh_release "localagi" "mudler/LocalAGI"; then + msg_info "Stopping LocalAGI service" + $STD systemctl stop localagi + msg_ok "Stopped LocalAGI service" - msg_info "Stopping LocalAGI service" - $STD systemctl stop localagi - msg_ok "Stopped LocalAGI service" + if [[ -f /opt/localagi/.env ]]; then + msg_info "Backing up existing LocalAGI configuration" + cp /opt/localagi/.env /tmp/localagi.env.backup + fi - if [[ -f /opt/localagi/.env ]]; then - msg_info "Backing up existing LocalAGI configuration" - cp /opt/localagi/.env /tmp/localagi.env.backup + msg_info "Fetching and deploying latest LocalAGI release" + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" + + msg_info "Restoring LocalAGI configuration" + if [[ -f /tmp/localagi.env.backup ]]; then + msg_info "Restoring LocalAGI configuration" + cp /tmp/localagi.env.backup /opt/localagi/.env + rm -f /tmp/localagi.env.backup + fi + + cd /opt/localagi/webui/react-ui + $STD bun install + $STD bun run build + cd /opt/localagi + $STD go build -o /usr/local/bin/localagi || { + msg_error "Failed to build LocalAGI from source" + exit 1 fi - - msg_info "Fetching and deploying latest LocalAGI release" - CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" - - msg_info "Restoring LocalAGI configuration" - if [[ -f /tmp/localagi.env.backup ]]; then - msg_info "Restoring LocalAGI configuration" - cp /tmp/localagi.env.backup /opt/localagi/.env - rm -f /tmp/localagi.env.backup - fi - - cd /opt/localagi/webui/react-ui - $STD bun install - $STD bun run build - cd /opt/localagi - $STD go build -o /usr/local/bin/localagi || { - msg_error "Failed to build LocalAGI from source" - exit 1 + exit } systemctl enable -q --now localagi From 420dee4678157d61a3ea1a4c4659d515768ec4ef Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:24:13 -0500 Subject: [PATCH 090/101] fix: improve update_script function by enhancing structure and readability --- ct/localagi.sh | 68 ++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index d0c5fe716..153d5c62f 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -22,43 +22,41 @@ color catch_errors function update_script() { - header_info - check_container_storage - check_container_resources - if check_for_gh_release "localagi" "mudler/LocalAGI"; then - msg_info "Stopping LocalAGI service" - $STD systemctl stop localagi - msg_ok "Stopped LocalAGI service" + header_info + check_container_storage + check_container_resources + if check_for_gh_release "localagi" "mudler/LocalAGI"; then + msg_info "Stopping LocalAGI service" + $STD systemctl stop localagi + msg_ok "Stopped LocalAGI service" - if [[ -f /opt/localagi/.env ]]; then - msg_info "Backing up existing LocalAGI configuration" - cp /opt/localagi/.env /tmp/localagi.env.backup + if [[ -f /opt/localagi/.env ]]; then + msg_info "Backing up existing LocalAGI configuration" + cp /opt/localagi/.env /tmp/localagi.env.backup + fi + + msg_info "Fetching and deploying latest LocalAGI release" + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" + + msg_info "Restoring LocalAGI configuration" + if [[ -f /tmp/localagi.env.backup ]]; then + msg_info "Restoring LocalAGI configuration" + cp /tmp/localagi.env.backup /opt/localagi/.env + rm -f /tmp/localagi.env.backup + fi + + cd /opt/localagi/webui/react-ui + $STD bun install + $STD bun run build + cd /opt/localagi + $STD go build -o /usr/local/bin/localagi || { + msg_error "Failed to build LocalAGI from source" + exit 1 + systemctl enable -q --now localagi + exit + } fi - - msg_info "Fetching and deploying latest LocalAGI release" - CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" - - msg_info "Restoring LocalAGI configuration" - if [[ -f /tmp/localagi.env.backup ]]; then - msg_info "Restoring LocalAGI configuration" - cp /tmp/localagi.env.backup /opt/localagi/.env - rm -f /tmp/localagi.env.backup - fi - - cd /opt/localagi/webui/react-ui - $STD bun install - $STD bun run build - cd /opt/localagi - $STD go build -o /usr/local/bin/localagi || { - msg_error "Failed to build LocalAGI from source" - exit 1 - fi - exit - } - - systemctl enable -q --now localagi - - exit + exit } start From c64024613b75b3b78b555b5fc903bcb2da850a6e Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:26:04 -0500 Subject: [PATCH 091/101] fix: remove error message and exit on build failure in update_script function --- ct/localagi.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 153d5c62f..1321be0e5 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -50,8 +50,6 @@ function update_script() { $STD bun run build cd /opt/localagi $STD go build -o /usr/local/bin/localagi || { - msg_error "Failed to build LocalAGI from source" - exit 1 systemctl enable -q --now localagi exit } From a9db3ba2e0abae182e3e355dec9e3cedc241f9c3 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:26:39 -0500 Subject: [PATCH 092/101] fix: add success message after updating LocalAGI in update_script function --- ct/localagi.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index 1321be0e5..fdaf922ca 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -50,6 +50,7 @@ function update_script() { $STD bun run build cd /opt/localagi $STD go build -o /usr/local/bin/localagi || { + msg_ok "Updated LocalAGI successfully" systemctl enable -q --now localagi exit } From 40a072f787033d121c20b489d5aaf08853324c09 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:27:37 -0500 Subject: [PATCH 093/101] fix: add informational messages for starting LocalAGI service in update_script function --- ct/localagi.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ct/localagi.sh b/ct/localagi.sh index fdaf922ca..5fd514a5d 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -51,7 +51,9 @@ function update_script() { cd /opt/localagi $STD go build -o /usr/local/bin/localagi || { msg_ok "Updated LocalAGI successfully" + msg_info "Starting LocalAGI service" systemctl enable -q --now localagi + mesg_ok "Started LocalAGI service" exit } fi From 8a1a4f8b9bb031964bf0582c582309be2344b0cf Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:28:54 -0500 Subject: [PATCH 094/101] fix: enhance Bun installation process with informational messages in localagi-install.sh --- install/localagi-install.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 73a769129..9c3abd64a 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -19,11 +19,12 @@ $STD apt install -y build-essential NODE_VERSION="24" setup_nodejs setup_go -$STD curl -fsSL -o /tmp/bun-install.sh https://bun.sh/install -$STD chmod +x /tmp/bun-install.sh -$STD bash /tmp/bun-install.sh -rm -f /tmp/bun-install.sh -[[ -x /root/.bun/bin/bun ]] && ln -sf /root/.bun/bin/bun /usr/local/bin/bun +msg_info "Installing Bun" +export BUN_INSTALL="/root/.bun" +curl -fsSL https://bun.sh/install | $STD bash +ln -sf /root/.bun/bin/bun /usr/local/bin/bun +ln -sf /root/.bun/bin/bunx /usr/local/bin/bunx +msg_ok "Installed Bun" fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" From c89dcca71ac0a37da29aacbd8dcdfbdda0a8bf95 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:29:23 -0500 Subject: [PATCH 095/101] fix: add informational messages for dependency installation in localagi-install.sh --- install/localagi-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 9c3abd64a..f44adde7a 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -14,7 +14,9 @@ setting_up_container network_check update_os +msg_info "Installing Dependencies" $STD apt install -y build-essential +msg_ok "Installed Dependencies" NODE_VERSION="24" setup_nodejs setup_go From 22fe50ee647275cddf8eb7ab18a29d4ce52f59c4 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:31:19 -0500 Subject: [PATCH 096/101] fix: add informational messages for fetching and building LocalAGI in localagi-install.sh --- install/localagi-install.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index f44adde7a..1664bc1ef 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -28,7 +28,9 @@ ln -sf /root/.bun/bin/bun /usr/local/bin/bun ln -sf /root/.bun/bin/bunx /usr/local/bin/bunx msg_ok "Installed Bun" +msg_info "Fetching and deploying LocalAGI" fetch_and_deploy_gh_release "localagi" "mudler/LocalAGI" "tarball" "latest" "/opt/localagi" +msg_ok "Fetched and deployed LocalAGI" mkdir -p /opt/localagi/pool cat <<'EOF' >/opt/localagi/.env @@ -42,14 +44,16 @@ LOCALAGI_ENABLE_CONVERSATIONS_LOGGING=false EOF chmod 600 /opt/localagi/.env -cd /opt/localagi/webui/react-ui && - $STD bun install && - $STD bun run build && - cd /opt/localagi && - $STD go build -o /usr/local/bin/localagi || { +msg_info "Building LocalAGI from source" +cd /opt/localagi/webui/react-ui +$STD bun install +$STD bun run build +cd /opt/localagi +$STD go build -o /usr/local/bin/localagi || { msg_error "Failed to build LocalAGI from source" exit 1 } +msg_ok "Built LocalAGI from source successfully" cat <<'EOF' >/etc/systemd/system/localagi.service [Unit] From 50485071594c28ed91eb5c8d096ef433855ab968 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:32:44 -0500 Subject: [PATCH 097/101] fix: remove error handling for LocalAGI build process in localagi-install.sh --- install/localagi-install.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 1664bc1ef..914816b13 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -49,10 +49,7 @@ cd /opt/localagi/webui/react-ui $STD bun install $STD bun run build cd /opt/localagi -$STD go build -o /usr/local/bin/localagi || { - msg_error "Failed to build LocalAGI from source" - exit 1 -} +$STD go build -o /usr/local/bin/localagi msg_ok "Built LocalAGI from source successfully" cat <<'EOF' >/etc/systemd/system/localagi.service From 3a1de5a78b4fc5919c739fa52f4b8a63911e02b9 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:33:29 -0500 Subject: [PATCH 098/101] fix: remove unused environment variables from LocalAGI configuration in localagi-install.sh --- install/localagi-install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index 914816b13..f0dc6eb48 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -39,10 +39,7 @@ LOCALAGI_MULTIMODAL_MODEL=moondream2-20250414 LOCALAGI_IMAGE_MODEL=sd-1.5-ggml LOCALAGI_LLM_API_URL=http://127.0.0.1:11434/v1 LOCALAGI_STATE_DIR=/opt/localagi/pool -LOCALAGI_TIMEOUT=5m -LOCALAGI_ENABLE_CONVERSATIONS_LOGGING=false EOF -chmod 600 /opt/localagi/.env msg_info "Building LocalAGI from source" cd /opt/localagi/webui/react-ui From d07d8f1054a911b0f86367f4fbc49f6eb5281792 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:35:30 -0500 Subject: [PATCH 099/101] fix: add informational messages for systemd service creation and management in localagi-install.sh --- install/localagi-install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install/localagi-install.sh b/install/localagi-install.sh index f0dc6eb48..e91fbbd41 100644 --- a/install/localagi-install.sh +++ b/install/localagi-install.sh @@ -49,6 +49,7 @@ cd /opt/localagi $STD go build -o /usr/local/bin/localagi msg_ok "Built LocalAGI from source successfully" +msg_info "Creating LocalAGI systemd service" cat <<'EOF' >/etc/systemd/system/localagi.service [Unit] Description=LocalAGI @@ -66,8 +67,11 @@ Restart=on-failure [Install] WantedBy=multi-user.target EOF +msg_ok "Created LocalAGI systemd service" +msg_info "Enabling and Starting LocalAGI service" systemctl enable -q --now localagi +msg_ok "Enabled and Started LocalAGI service" motd_ssh customize From 7fe554e2beb23f07080f5c14a50593c5c7eea5b8 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 15:40:56 -0500 Subject: [PATCH 100/101] fix: update LocalAGI service management in update_script function --- ct/localagi.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 5fd514a5d..50e5ff132 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -52,8 +52,9 @@ function update_script() { $STD go build -o /usr/local/bin/localagi || { msg_ok "Updated LocalAGI successfully" msg_info "Starting LocalAGI service" - systemctl enable -q --now localagi - mesg_ok "Started LocalAGI service" + systemctl daemon-reload + systemctl start localagi + msg_ok "Started LocalAGI service" exit } fi From 3b0f9ea35d89058ed87ceb126b99dc0d7910fed4 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 5 Mar 2026 17:04:22 -0500 Subject: [PATCH 101/101] fix: simplify default value for var_tags in localagi.sh --- ct/localagi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ct/localagi.sh b/ct/localagi.sh index 50e5ff132..751390ad0 100644 --- a/ct/localagi.sh +++ b/ct/localagi.sh @@ -7,7 +7,7 @@ source <(curl -sSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE # Source: https://github.com/mudler/LocalAGI APP="LocalAGI" -var_tags="${var_tags:-ai,agents}" +var_tags="${var_tags:-ai}" var_cpu="${var_cpu:-2}" var_ram="${var_ram:-4096}" var_disk="${var_disk:-20}"