From bf2eaffccf7ccfc0cc466f652535b203e658e868 Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Fri, 9 Oct 2026 06:16:42 +0000 Subject: [PATCH 1/3] Add localai (ct) --- ct/localai.sh | 67 ++++++++++++++++++++++++++ install/localai-install.sh | 99 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 ct/localai.sh create mode 100644 install/localai-install.sh diff --git a/ct/localai.sh b/ct/localai.sh new file mode 100644 index 00000000000..847ef3378f9 --- /dev/null +++ b/ct/localai.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func" +source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func") +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Bryan Lieberman (BryanCLieberman) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://localai.io + +APP="LocalAI" +var_tags="${var_tags:-ai;llm;api}" +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_gpu="${var_gpu:-yes}" +var_unprivileged="${var_unprivileged:-1}" +# var_arm64 left unset: upstream ships a linux-arm64 asset, but this has never +# been run on an arm64 host, so arch_check asks rather than claiming support. + +# Values the install script accepts up front - without the export they never +# reach the container. +export var_auth="${var_auth:-no}" +export var_api_key="${var_api_key:-}" +export var_port="${var_port:-8080}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -d /opt/localai ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "localai" "mudler/LocalAI"; then + msg_info "Stopping Service" + systemctl stop localai + msg_ok "Stopped Service" + + # Models, backends and the env file live outside /opt/localai, so a clean + # install only ever replaces the binary. + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localai" "mudler/LocalAI" "singlefile" "latest" "/opt/localai" "local-ai-v*-linux-$(arch_resolve amd64 arm64)" + + msg_info "Starting Service" + systemctl start localai + msg_ok "Started Service" + msg_ok "Updated 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 "${GATEWAY}${BGN}http://${IP}:8080${CL}" +echo -e "${INFO}${YW}Install models from the gallery in the web UI or place GGUF files in /opt/localai_data/models${CL}" \ No newline at end of file diff --git a/install/localai-install.sh b/install/localai-install.sh new file mode 100644 index 00000000000..7780773efe1 --- /dev/null +++ b/install/localai-install.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: Bryan Lieberman (BryanCLieberman) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://localai.io + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +var_port="${var_port:-8080}" +var_auth="${var_auth:-no}" +var_api_key="${var_api_key:-}" + +msg_info "Installing Dependencies" +$STD apt install -y \ + libgomp1 \ + libopenblas0 +msg_ok "Installed Dependencies" + +setup_hwaccel + +# The account system stores users, roles and sessions in SQLite by default, but +# that needs a CGO build (-tags auth) which upstream does not ship in the release +# binary. PostgreSQL is the supported alternative and needs no CGO. +if [[ "$var_auth" == "yes" ]]; then + setup_postgresql + PG_DB_NAME="localai" PG_DB_USER="localai" setup_postgresql_db +fi + +fetch_and_deploy_gh_release "localai" "mudler/LocalAI" "singlefile" "latest" "/opt/localai" "local-ai-v*-linux-$(arch_resolve amd64 arm64)" + +msg_info "Configuring LocalAI" +# Models, backends and the auth database are kept outside /opt/localai so an +# update can replace the binary without touching any of them. +mkdir -p /opt/localai_data/models /opt/localai_data/backends +cat </opt/localai.env +LOCALAI_ADDRESS=0.0.0.0:${var_port} +LOCALAI_DATA_PATH=/opt/localai_data +LOCALAI_MODELS_PATH=/opt/localai_data/models +LOCALAI_BACKENDS_PATH=/opt/localai_data/backends +LOCALAI_LOG_LEVEL=info +EOF +# LocalAI refuses to start on a wildcard bind with nothing to identify callers, +# and binding the wildcard is what makes the container reachable at all. +if [[ "$var_auth" == "yes" ]]; then + cat <>/opt/localai.env +LOCALAI_AUTH=true +LOCALAI_AUTH_DATABASE_URL=postgres://${PG_DB_USER}:${PG_DB_PASS}@localhost/${PG_DB_NAME} +LOCALAI_REGISTRATION_MODE=approval +EOF +fi +# A static key grants admin access on its own, so when it is the only thing +# guarding the API, generate one rather than leaving the server open. +if [[ -z "$var_api_key" && "$var_auth" != "yes" ]]; then + var_api_key="sk-$(openssl rand -hex 24)" + { + echo "LocalAI Credentials" + echo "API Key: ${var_api_key}" + } >>~/localai.creds +fi +if [[ -n "$var_api_key" ]]; then + echo "LOCALAI_API_KEY=${var_api_key}" >>/opt/localai.env +else + echo "#LOCALAI_API_KEY=" >>/opt/localai.env +fi +chmod 600 /opt/localai.env +msg_ok "Configured LocalAI" + +msg_info "Creating Service" +cat </etc/systemd/system/localai.service +[Unit] +Description=LocalAI Server +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/localai +EnvironmentFile=/opt/localai.env +ExecStart=/opt/localai/localai run +Restart=on-failure +RestartSec=10 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now localai +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc \ No newline at end of file From 8a4c1883b0c553b0e08f444bb1c021032a3bb627 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Fri, 9 Oct 2026 08:28:37 +0200 Subject: [PATCH 2/3] Refactor localai.sh to clean up comments and exports Removed comments regarding ARM64 support and clarified install script export variables. --- ct/localai.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ct/localai.sh b/ct/localai.sh index 847ef3378f9..20ecfabafd8 100644 --- a/ct/localai.sh +++ b/ct/localai.sh @@ -13,13 +13,11 @@ var_ram="${var_ram:-8192}" var_disk="${var_disk:-30}" var_os="${var_os:-debian}" var_version="${var_version:-13}" +var_arm64="${var_arm64:-yes}" var_gpu="${var_gpu:-yes}" var_unprivileged="${var_unprivileged:-1}" -# var_arm64 left unset: upstream ships a linux-arm64 asset, but this has never -# been run on an arm64 host, so arch_check asks rather than claiming support. -# Values the install script accepts up front - without the export they never -# reach the container. +# Values the install script accepts up front export var_auth="${var_auth:-no}" export var_api_key="${var_api_key:-}" export var_port="${var_port:-8080}" @@ -44,8 +42,6 @@ function update_script() { systemctl stop localai msg_ok "Stopped Service" - # Models, backends and the env file live outside /opt/localai, so a clean - # install only ever replaces the binary. CLEAN_INSTALL=1 fetch_and_deploy_gh_release "localai" "mudler/LocalAI" "singlefile" "latest" "/opt/localai" "local-ai-v*-linux-$(arch_resolve amd64 arm64)" msg_info "Starting Service" @@ -64,4 +60,4 @@ 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 "${GATEWAY}${BGN}http://${IP}:8080${CL}" -echo -e "${INFO}${YW}Install models from the gallery in the web UI or place GGUF files in /opt/localai_data/models${CL}" \ No newline at end of file +echo -e "${INFO}${YW}Install models from the gallery in the web UI or place GGUF files in /opt/localai_data/models${CL}" From a85068e45c44e526e1f8b54a5e78eaa0adf21e7c Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Fri, 9 Oct 2026 08:29:28 +0200 Subject: [PATCH 3/3] Refactor variable assignments and clean up comments Rearranged variable assignments and removed comments about SQLite and PostgreSQL. --- install/localai-install.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/install/localai-install.sh b/install/localai-install.sh index 7780773efe1..2171e2c1ea1 100644 --- a/install/localai-install.sh +++ b/install/localai-install.sh @@ -13,10 +13,6 @@ setting_up_container network_check update_os -var_port="${var_port:-8080}" -var_auth="${var_auth:-no}" -var_api_key="${var_api_key:-}" - msg_info "Installing Dependencies" $STD apt install -y \ libgomp1 \ @@ -24,10 +20,9 @@ $STD apt install -y \ msg_ok "Installed Dependencies" setup_hwaccel - -# The account system stores users, roles and sessions in SQLite by default, but -# that needs a CGO build (-tags auth) which upstream does not ship in the release -# binary. PostgreSQL is the supported alternative and needs no CGO. +var_port="${var_port:-8080}" +var_auth="${var_auth:-no}" +var_api_key="${var_api_key:-}" if [[ "$var_auth" == "yes" ]]; then setup_postgresql PG_DB_NAME="localai" PG_DB_USER="localai" setup_postgresql_db @@ -36,8 +31,6 @@ fi fetch_and_deploy_gh_release "localai" "mudler/LocalAI" "singlefile" "latest" "/opt/localai" "local-ai-v*-linux-$(arch_resolve amd64 arm64)" msg_info "Configuring LocalAI" -# Models, backends and the auth database are kept outside /opt/localai so an -# update can replace the binary without touching any of them. mkdir -p /opt/localai_data/models /opt/localai_data/backends cat </opt/localai.env LOCALAI_ADDRESS=0.0.0.0:${var_port} @@ -96,4 +89,4 @@ msg_ok "Created Service" motd_ssh customize -cleanup_lxc \ No newline at end of file +cleanup_lxc