diff --git a/ct/openwebui.sh b/ct/openwebui.sh index ec1122dbe..402fd2dc7 100644 --- a/ct/openwebui.sh +++ b/ct/openwebui.sh @@ -23,6 +23,62 @@ function update_script() { header_info check_container_storage check_container_resources + + 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 + 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 $PYTHON_VERSION 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 + rm -rf /opt/open-webui-backup || true + msg_ok "Restored data" + + msg_info "Recreating Service" + cat </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 @@ -50,8 +106,11 @@ function update_script() { fi fi - msg_info "Restarting Open WebUI to initiate update" + msg_info "Updating Open WebUI via uv" + PYTHON_VERSION="3.12" setup_uv + $STD uv tool install --python 3.12 open-webui[all] systemctl restart open-webui + msg_ok "Updated Open WebUI" msg_ok "Updated successfully!" exit } diff --git a/install/openwebui-install.sh b/install/openwebui-install.sh index ad43ac7c3..2be6290ec 100644 --- a/install/openwebui-install.sh +++ b/install/openwebui-install.sh @@ -17,7 +17,11 @@ msg_info "Installing Dependencies" $STD apt install -y ffmpeg msg_ok "Installed Dependencies" -USE_UVX="YES" PYTHON_VERSION="3.12" setup_uv +PYTHON_VERSION="3.12" setup_uv + +msg_info "Installing Open WebUI" +$STD uv tool install --python 3.12 open-webui[all] +msg_ok "Installed Open WebUI" read -r -p "${TAB3}Would you like to add Ollama? " prompt if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then @@ -56,7 +60,7 @@ After=network.target Type=simple EnvironmentFile=-/root/.env Environment=DATA_DIR=/root/.open-webui -ExecStart=/usr/local/bin/uvx --python 3.12 open-webui@latest serve +ExecStart=/root/.local/bin/open-webui serve WorkingDirectory=/root Restart=on-failure RestartSec=5 @@ -70,9 +74,4 @@ msg_ok "Created Service" motd_ssh customize - -msg_info "Cleaning up" -$STD apt -y autoremove -$STD apt -y autoclean -$STD apt -y clean -msg_ok "Cleaned" +cleanup_lxc