fix: update source URL and improve Bun installation in LocalAGI scripts

This commit is contained in:
John Doe
2026-03-04 20:58:03 -05:00
parent b844eab504
commit 8a3d6f3a2b
2 changed files with 84 additions and 223 deletions

View File

@@ -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 <<EOF
Version: ${release_tag}
InstallDate: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
InstallMethod: ct
Source: mudler/LocalAGI
EOF
msg_ok "Recorded release: $release_tag"
else
msg_warn "Could not determine release tag for LocalAGI"
fi
# Running service as root per project guidelines (AI.md)
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"
[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
}

View File

@@ -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 <<EOF
Version: ${release_tag}
InstallDate: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
InstallMethod: ${METHOD:-install}
Source: mudler/LocalAGI
EOF
msg_ok "Recorded release: $release_tag"
else
msg_warn "Could not determine release tag for LocalAGI"
fi
msg_info "Recording installed version"
record_gh_release_version "localagi" "mudler/LocalAGI"
msg_ok "Recorded installed version"
mkdir -p /opt/localagi/pool
msg_info "Configuring LocalAGI"
cat <<'EOF' >/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 <<EOF >"$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