mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-11-16 19:08:30 +01:00
Ollama/OpenWebUI: download update before stopping the service
Stage the release in <dir>.new while Ollama keeps running, stop the service only for the directory swap. A failed or stalled download no longer leaves the container without an Ollama binary. Restores the intent of #9894, which was lost in the tools.func refactor (#14501).
This commit is contained in:
1 parent
362aad1ed9
commit
d0571b404f
2 files changed
+40
-20
No files matched your search
+17
-7
@@ -34,18 +34,28 @@ function update_script() {
|
||||
|
||||
if check_for_gh_release "ollama-com" "ollama/ollama"; then
|
||||
ensure_dependencies zstd
|
||||
# Download into a staging dir while Ollama keeps serving, stop it only for the swap.
|
||||
# The release tarball is >1.5 GB: stopping first meant long downtime on slow links,
|
||||
# and a failed download left the container without any Ollama binary.
|
||||
OLLAMA_INSTALL_DIR="/usr/local/lib/ollama"
|
||||
OLLAMA_STAGING_DIR="${OLLAMA_INSTALL_DIR}.new"
|
||||
rm -rf "$OLLAMA_STAGING_DIR"
|
||||
mkdir -p "$OLLAMA_STAGING_DIR"
|
||||
if ! fetch_and_deploy_gh_release "ollama-com" "ollama/ollama" "prebuild" "latest" "$OLLAMA_STAGING_DIR" "ollama-linux-$(arch_resolve).tar.zst"; then
|
||||
rm -rf "$OLLAMA_STAGING_DIR"
|
||||
msg_error "Download or deployment failed – check network connectivity and GitHub API availability (installed Ollama left unchanged)"
|
||||
exit 250
|
||||
fi
|
||||
|
||||
msg_info "Stopping Services"
|
||||
systemctl stop ollama
|
||||
msg_ok "Services Stopped"
|
||||
|
||||
OLLAMA_INSTALL_DIR="/usr/local/lib/ollama"
|
||||
rm -rf "$OLLAMA_INSTALL_DIR" /usr/local/bin/ollama
|
||||
mkdir -p "$OLLAMA_INSTALL_DIR"
|
||||
if ! fetch_and_deploy_gh_release "ollama-com" "ollama/ollama" "prebuild" "latest" "$OLLAMA_INSTALL_DIR" "ollama-linux-$(arch_resolve).tar.zst"; then
|
||||
msg_error "Download or deployment failed – check network connectivity and GitHub API availability"
|
||||
exit 250
|
||||
fi
|
||||
rm -rf "${OLLAMA_INSTALL_DIR}.old"
|
||||
mv "$OLLAMA_INSTALL_DIR" "${OLLAMA_INSTALL_DIR}.old"
|
||||
mv "$OLLAMA_STAGING_DIR" "$OLLAMA_INSTALL_DIR"
|
||||
ln -sf "$OLLAMA_INSTALL_DIR/bin/ollama" /usr/local/bin/ollama
|
||||
rm -rf "${OLLAMA_INSTALL_DIR}.old"
|
||||
msg_ok "Updated Ollama"
|
||||
|
||||
msg_info "Starting Services"
|
||||
|
||||
+23
-13
@@ -101,21 +101,31 @@ EOF
|
||||
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"
|
||||
# Download into a staging dir while Ollama keeps serving, stop it only for the swap
|
||||
# (same pattern as ct/ollama.sh; a failed download leaves the running Ollama untouched).
|
||||
rm -rf /usr/lib/ollama.new
|
||||
mkdir -p /usr/lib/ollama.new
|
||||
if ! fetch_and_deploy_gh_release "ollama-com" "ollama/ollama" "prebuild" "latest" "/usr/lib/ollama.new" "ollama-linux-$(arch_resolve).tar.zst"; then
|
||||
rm -rf /usr/lib/ollama.new
|
||||
msg_error "Ollama download or deployment failed – check network connectivity and GitHub API availability (installed Ollama left unchanged)"
|
||||
else
|
||||
ln -sf /usr/lib/ollama/bin/ollama /usr/bin/ollama
|
||||
msg_ok "Updated Ollama to ${CHECK_UPDATE_RELEASE}"
|
||||
fi
|
||||
msg_info "Stopping Ollama Service"
|
||||
systemctl stop ollama
|
||||
msg_ok "Stopped Service"
|
||||
|
||||
msg_info "Starting Ollama Service"
|
||||
systemctl start ollama
|
||||
msg_ok "Started Service"
|
||||
rm -rf /usr/lib/ollama.old
|
||||
if [[ -d /usr/lib/ollama ]]; then
|
||||
mv /usr/lib/ollama /usr/lib/ollama.old
|
||||
fi
|
||||
mv /usr/lib/ollama.new /usr/lib/ollama
|
||||
ln -sf /usr/lib/ollama/bin/ollama /usr/bin/ollama
|
||||
rm -rf /usr/lib/ollama.old
|
||||
msg_ok "Updated Ollama to ${CHECK_UPDATE_RELEASE}"
|
||||
|
||||
msg_info "Starting Ollama Service"
|
||||
systemctl start ollama
|
||||
msg_ok "Started Service"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user