Skip to content

Commit 26090ba

Browse files
Migrate Open WebUI to uv-based installation (#9019)
* Migrate Open WebUI to uv-based installation Added migration logic to detect and upgrade legacy Open WebUI installations to a uv-based setup, including data backup and service recreation. Updated install and update scripts to use uv for installing Open WebUI and adjusted service configuration and cleanup steps accordingly. * english --------- Co-authored-by: Tobias <[email protected]>
1 parent 787a99f commit 26090ba

File tree

2 files changed

+67
-9
lines changed

2 files changed

+67
-9
lines changed

ct/openwebui.sh

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,62 @@ function update_script() {
2323
header_info
2424
check_container_storage
2525
check_container_resources
26+
27+
if [[ -d /opt/open-webui ]]; then
28+
msg_warn "Legacy installation detected — migrating to uv based install..."
29+
msg_info "Stopping Service"
30+
systemctl stop open-webui
31+
msg_ok "Stopped Service"
32+
33+
msg_info "Creating Backup"
34+
mkdir -p /opt/open-webui-backup
35+
cp -a /opt/open-webui/backend/data /opt/open-webui-backup/data || true
36+
msg_ok "Created Backup"
37+
38+
msg_info "Removing legacy installation"
39+
rm -rf /opt/open-webui
40+
rm -rf /root/.open-webui || true
41+
msg_ok "Removed legacy installation"
42+
43+
msg_info "Installing uv-based Open-WebUI"
44+
PYTHON_VERSION="3.12" setup_uv
45+
$STD uv tool install --python $PYTHON_VERSION open-webui[all]
46+
msg_ok "Installed uv-based Open-WebUI"
47+
48+
msg_info "Restoring data"
49+
mkdir -p /root/.open-webui
50+
cp -a /opt/open-webui-backup/data/* /root/.open-webui/ || true
51+
rm -rf /opt/open-webui-backup || true
52+
msg_ok "Restored data"
53+
54+
msg_info "Recreating Service"
55+
cat <<EOF >/etc/systemd/system/open-webui.service
56+
[Unit]
57+
Description=Open WebUI Service
58+
After=network.target
59+
60+
[Service]
61+
Type=simple
62+
Environment=DATA_DIR=/root/.open-webui
63+
EnvironmentFile=-/root/.env
64+
ExecStart=/root/.local/bin/open-webui serve
65+
WorkingDirectory=/root
66+
Restart=on-failure
67+
RestartSec=5
68+
User=root
69+
70+
[Install]
71+
WantedBy=multi-user.target
72+
EOF
73+
74+
$STD systemctl daemon-reload
75+
systemctl enable -q --now open-webui
76+
msg_ok "Recreated Service"
77+
78+
msg_ok "Migration completed"
79+
exit 0
80+
fi
81+
2682
if [[ ! -d /root/.open-webui ]]; then
2783
msg_error "No ${APP} Installation Found!"
2884
exit
@@ -50,8 +106,11 @@ function update_script() {
50106
fi
51107
fi
52108

53-
msg_info "Restarting Open WebUI to initiate update"
109+
msg_info "Updating Open WebUI via uv"
110+
PYTHON_VERSION="3.12" setup_uv
111+
$STD uv tool install --python 3.12 open-webui[all]
54112
systemctl restart open-webui
113+
msg_ok "Updated Open WebUI"
55114
msg_ok "Updated successfully!"
56115
exit
57116
}

install/openwebui-install.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ msg_info "Installing Dependencies"
1717
$STD apt install -y ffmpeg
1818
msg_ok "Installed Dependencies"
1919

20-
USE_UVX="YES" PYTHON_VERSION="3.12" setup_uv
20+
PYTHON_VERSION="3.12" setup_uv
21+
22+
msg_info "Installing Open WebUI"
23+
$STD uv tool install --python 3.12 open-webui[all]
24+
msg_ok "Installed Open WebUI"
2125

2226
read -r -p "${TAB3}Would you like to add Ollama? <y/N> " prompt
2327
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
@@ -56,7 +60,7 @@ After=network.target
5660
Type=simple
5761
EnvironmentFile=-/root/.env
5862
Environment=DATA_DIR=/root/.open-webui
59-
ExecStart=/usr/local/bin/uvx --python 3.12 open-webui@latest serve
63+
ExecStart=/root/.local/bin/open-webui serve
6064
WorkingDirectory=/root
6165
Restart=on-failure
6266
RestartSec=5
@@ -70,9 +74,4 @@ msg_ok "Created Service"
7074

7175
motd_ssh
7276
customize
73-
74-
msg_info "Cleaning up"
75-
$STD apt -y autoremove
76-
$STD apt -y autoclean
77-
$STD apt -y clean
78-
msg_ok "Cleaned"
77+
cleanup_lxc

0 commit comments

Comments
 (0)