Files
ProxmoxVE/ct/openwebui.sh
CanbiZ (MickLesk) 8854585a1a Migrate the (remaining) Top 25 scripts to the new core engine (#16749)
* Move the top 25 scripts onto the core engine

The engine work of the last few days reaches 30 of 561 ct scripts, about 5% of
ProxmoxVE traffic: retry on engine downloads, exit 227 instead of a misfiled
dpkg error, the umask fix that stops a hardened host producing containers apt
cannot resolve in, the TMPDIR guard, the toolchain restore. All of it has been
sitting where almost nobody runs it.

All eighteen at once rather than in waves. A slow rollout does not exercise the
paths only some scripts take, and broad exposure is what surfaces bugs -- a
deliberate call about release risk.

Checked before touching anything, because "migrate" meant far more than a line
swap last time:

  - None of the eighteen has an alpine-* variant, so there is no merge to do.
  - No script references misc/ outside its bootstrap line.
  - Of the 61 functions that exist only in misc/, none is called by any of them.

So it is one line per script, and every head is now byte-identical to the ones
migrated earlier. With these, ProxmoxVE goes from 30 scripts on the core engine
to 48 -- and from roughly 5% of traffic to the majority, since these are the
ones people actually install.

Two to watch: immich sits at 44.7% success and vaultwarden at 42.1% before
this. If their numbers move, the engine is one of two changed variables rather
than the only one.

* Move update-apps onto the core engine

Entry 11 of the list and the only one that is not a ct script, so it was left
out of the previous commit. It is a host tool: it never used build.func at all,
it sources misc/core.func and misc/api.func directly.

The swap is therefore two lines rather than one, and worth checking rather than
assuming. It uses exactly five engine functions -- header_info,
init_tool_telemetry, msg_info, msg_ok, msg_error -- all present in the core, and
both files load standalone, which they had not had to do before: everywhere else
they arrive through build.func.

That completes the list. All 25 now run on the core engine.

Fixing this one matters beyond the migration: update-apps is what drives
unattended updates across every container on a host, and it is the path where
PHS_SILENT was being ignored (#16593). It now gets the engine that honours it.
2026-08-25 11:04:15 +02:00

141 lines
4.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
_CS_DEFAULT_URL="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main"
_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 tteck
# Author: tteck | Co-Author: havardthom | Co-Author: Slaviša Arežina (tremor021)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://openwebui.com/
APP="Open WebUI"
var_tags="${var_tags:-ai;interface}"
var_cpu="${var_cpu:-4}"
var_ram="${var_ram:-8192}"
var_disk="${var_disk:-50}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_arm64="${var_arm64:-yes}"
var_unprivileged="${var_unprivileged:-1}"
var_gpu="${var_gpu:-yes}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
ensure_dependencies zstd build-essential libmariadb-dev
[[ -f /root/.ollama ]] && rm -f /root/.ollama
if [[ -d /opt/open-webui ]]; then
msg_warn "Legacy installation detected — migrating to uv based install..."
msg_info "Stopping Service"
systemctl stop open-webui
msg_ok "Stopped Service"
msg_info "Creating Backup"
mkdir -p /opt/open-webui-backup
cp -a /opt/open-webui/backend/data /opt/open-webui-backup/data || true
cp -a /opt/open-webui/.env /opt/open-webui-backup/.env || true
msg_ok "Created Backup"
msg_info "Removing legacy installation"
rm -rf /opt/open-webui
rm -rf /root/.open-webui || true
msg_ok "Removed legacy installation"
msg_info "Installing uv-based Open-WebUI"
PYTHON_VERSION="3.12" setup_uv
$STD uv tool install --python 3.12 --constraint <(echo "numba>=0.60") open-webui[all]
msg_ok "Installed uv-based Open-WebUI"
msg_info "Restoring data"
mkdir -p /root/.open-webui
cp -a /opt/open-webui-backup/data/* /root/.open-webui/ || true
cp -a /opt/open-webui-backup/.env /root/.env || true
rm -rf /opt/open-webui-backup || true
msg_ok "Restored data"
msg_info "Recreating Service"
cat <<EOF >/etc/systemd/system/open-webui.service
[Unit]
Description=Open WebUI Service
After=network.target
[Service]
Type=simple
Environment=DATA_DIR=/root/.open-webui
EnvironmentFile=-/root/.env
ExecStart=/root/.local/bin/open-webui serve
WorkingDirectory=/root
Restart=on-failure
RestartSec=5
User=root
[Install]
WantedBy=multi-user.target
EOF
$STD systemctl daemon-reload
systemctl enable -q --now open-webui
msg_ok "Recreated Service"
msg_ok "Migration completed"
exit 0
fi
if [[ ! -d /root/.open-webui ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if [ -x "/usr/bin/ollama" ]; then
msg_info "Checking for Ollama Update"
if check_for_gh_release "ollama-com" "ollama/ollama"; then
msg_info "Stopping Ollama Service"
systemctl stop ollama
msg_ok "Stopped Service"
rm -rf /usr/lib/ollama /usr/bin/ollama
if ! fetch_and_deploy_gh_release "ollama-com" "ollama/ollama" "prebuild" "latest" "/usr/lib/ollama" "ollama-linux-$(arch_resolve).tar.zst"; then
msg_error "Ollama download or deployment failed check network connectivity and GitHub API availability"
else
ln -sf /usr/lib/ollama/bin/ollama /usr/bin/ollama
msg_ok "Updated Ollama to ${CHECK_UPDATE_RELEASE}"
fi
msg_info "Starting Ollama Service"
systemctl start ollama
msg_ok "Started Service"
fi
fi
msg_info "Updating Open WebUI via uv"
PYTHON_VERSION="3.12" setup_uv
OWUI_PYTHON="/root/.local/share/uv/tools/open-webui/bin/python3.12"
OTEL_ARGS=()
if [[ -x "$OWUI_PYTHON" ]]; then
while IFS= read -r pkg; do
OTEL_ARGS+=(--with "$pkg")
done < <(uv pip list --python "$OWUI_PYTHON" --format freeze 2>/dev/null | grep -i '^opentelemetry-' | cut -d= -f1)
fi
$STD uv tool install --force --python 3.12 --constraint <(echo "numba>=0.60") "${OTEL_ARGS[@]}" open-webui[all]
systemctl restart open-webui
msg_ok "Updated Open WebUI"
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 "${GATEWAY}${BGN}http://${IP}:8080${CL}"