Files
ProxmoxVEDHelperScripts/ct/localagi.sh

109 lines
2.7 KiB
Bash

#!/usr/bin/env bash
source <(curl -sSL https://raw.githubusercontent.com/asylumexp/ProxmoxVED/main/misc/build.func)
# Copyright (c) 2021-2026 community-scripts ORG
# Author: BillyOutlast
# 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:-2}"
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}"
var_gpu="${var_gpu:-no}"
header_info "$APP"
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
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"
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
}
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}:3000${CL}"