diff --git a/ct/ollama.sh b/ct/ollama.sh index a8c12982e..04ca299e7 100644 --- a/ct/ollama.sh +++ b/ct/ollama.sh @@ -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" diff --git a/ct/openwebui.sh b/ct/openwebui.sh index 044c6af29..52ea78508 100644 --- a/ct/openwebui.sh +++ b/ct/openwebui.sh @@ -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