From 05ea89e3d05571ea1fc84d62c9b316bd0c281aa5 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 4 Mar 2026 20:45:04 -0500 Subject: [PATCH] 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"