|
|
|
@ -1,9 +1,8 @@ |
|
|
|
#!/usr/bin/env bash |
|
|
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) |
|
|
|
|
|
|
|
# Copyright (c) 2021-2026 tteck |
|
|
|
# Author: havardthom | Co-Author: MickLesk (CanbiZ) |
|
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
|
|
|
# Source: https://ollama.com/ |
|
|
|
# Modified for custom mirror download |
|
|
|
|
|
|
|
APP="Ollama" |
|
|
|
var_tags="${var_tags:-ai}" |
|
|
|
@ -14,50 +13,94 @@ var_os="${var_os:-ubuntu}" |
|
|
|
var_version="${var_version:-24.04}" |
|
|
|
var_gpu="${var_gpu:-yes}" |
|
|
|
|
|
|
|
# 🔥 YOUR MIRROR |
|
|
|
OLLAMA_MIRROR="https://file.wifibills.com/ollama-linux-amd64.tar.zst" |
|
|
|
|
|
|
|
header_info "$APP" |
|
|
|
variables |
|
|
|
color |
|
|
|
catch_errors |
|
|
|
|
|
|
|
function download_ollama() { |
|
|
|
TMP_TAR=$(mktemp --suffix=.tar.zst) |
|
|
|
|
|
|
|
msg_info "Trying local mirror..." |
|
|
|
if curl -fL# -o "${TMP_TAR}" "${OLLAMA_MIRROR}"; then |
|
|
|
msg_ok "Downloaded from mirror" |
|
|
|
else |
|
|
|
msg_info "Mirror failed, trying GitHub..." |
|
|
|
curl -fL# -o "${TMP_TAR}" \ |
|
|
|
"https://github.com/ollama/ollama/releases/latest/download/ollama-linux-amd64.tar.zst" || { |
|
|
|
msg_error "Download failed from both mirror and GitHub!" |
|
|
|
exit 1 |
|
|
|
} |
|
|
|
fi |
|
|
|
|
|
|
|
echo "${TMP_TAR}" |
|
|
|
} |
|
|
|
|
|
|
|
function install_ollama() { |
|
|
|
msg_info "Installing Ollama" |
|
|
|
|
|
|
|
ensure_dependencies curl zstd |
|
|
|
|
|
|
|
TAR_FILE=$(download_ollama) |
|
|
|
|
|
|
|
rm -rf /usr/local/lib/ollama |
|
|
|
rm -rf /usr/local/bin/ollama |
|
|
|
|
|
|
|
mkdir -p /usr/local/lib/ollama |
|
|
|
tar --zstd -xf "${TAR_FILE}" -C /usr/local/lib/ollama |
|
|
|
ln -sf /usr/local/lib/ollama/bin/ollama /usr/local/bin/ollama |
|
|
|
rm -f "${TAR_FILE}" |
|
|
|
|
|
|
|
cat <<EOF >/etc/systemd/system/ollama.service |
|
|
|
[Unit] |
|
|
|
Description=Ollama Service |
|
|
|
After=network.target |
|
|
|
|
|
|
|
[Service] |
|
|
|
ExecStart=/usr/local/bin/ollama serve |
|
|
|
Restart=always |
|
|
|
User=root |
|
|
|
Group=root |
|
|
|
|
|
|
|
[Install] |
|
|
|
WantedBy=multi-user.target |
|
|
|
EOF |
|
|
|
|
|
|
|
systemctl daemon-reload |
|
|
|
systemctl enable ollama |
|
|
|
systemctl start ollama |
|
|
|
|
|
|
|
msg_ok "Ollama Installed Successfully" |
|
|
|
} |
|
|
|
|
|
|
|
function update_script() { |
|
|
|
header_info |
|
|
|
check_container_storage |
|
|
|
check_container_resources |
|
|
|
|
|
|
|
if [[ ! -d /usr/local/lib/ollama ]]; then |
|
|
|
msg_error "No Ollama Installation Found!" |
|
|
|
exit |
|
|
|
fi |
|
|
|
RELEASE=$(curl -fsSL https://api.github.com/repos/ollama/ollama/releases/latest | grep "tag_name" | awk -F '"' '{print $4}') |
|
|
|
if [[ ! -f /opt/Ollama_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/Ollama_version.txt)" ]]; then |
|
|
|
if [[ ! -f /opt/Ollama_version.txt ]]; then |
|
|
|
touch /opt/Ollama_version.txt |
|
|
|
fi |
|
|
|
ensure_dependencies zstd |
|
|
|
msg_info "Stopping Services" |
|
|
|
|
|
|
|
msg_info "Stopping Ollama service" |
|
|
|
systemctl stop ollama |
|
|
|
msg_ok "Services Stopped" |
|
|
|
|
|
|
|
TMP_TAR=$(mktemp --suffix=.tar.zst) |
|
|
|
msg_info "Downloading Ollama from local mirror" |
|
|
|
curl -fL# -o "${TMP_TAR}" "https://file.wifibills.com/ollama-linux-amd64.tar.zst" |
|
|
|
msg_info "Installing Ollama ${RELEASE}" |
|
|
|
TAR_FILE=$(download_ollama) |
|
|
|
|
|
|
|
rm -rf /usr/local/lib/ollama |
|
|
|
rm -rf /usr/local/bin/ollama |
|
|
|
|
|
|
|
mkdir -p /usr/local/lib/ollama |
|
|
|
tar --zstd -xf "${TMP_TAR}" -C /usr/local/lib/ollama |
|
|
|
tar --zstd -xf "${TAR_FILE}" -C /usr/local/lib/ollama |
|
|
|
ln -sf /usr/local/lib/ollama/bin/ollama /usr/local/bin/ollama |
|
|
|
rm -f "${TMP_TAR}" |
|
|
|
echo "${RELEASE}" >/opt/Ollama_version.txt |
|
|
|
msg_ok "Updated Ollama to ${RELEASE}" |
|
|
|
rm -f "${TAR_FILE}" |
|
|
|
|
|
|
|
msg_info "Starting Services" |
|
|
|
systemctl start ollama |
|
|
|
msg_ok "Started Services" |
|
|
|
msg_ok "Updated successfully!" |
|
|
|
else |
|
|
|
msg_ok "No update required. Ollama is already at ${RELEASE}" |
|
|
|
fi |
|
|
|
msg_ok "Ollama Updated Successfully" |
|
|
|
exit |
|
|
|
} |
|
|
|
|
|
|
|
@ -65,7 +108,10 @@ start |
|
|
|
build_container |
|
|
|
description |
|
|
|
|
|
|
|
msg_ok "Completed successfully!\n" |
|
|
|
msg_info "Running Ollama installer inside container" |
|
|
|
pct exec $CTID -- bash -c "$(declare -f install_ollama download_ollama); install_ollama" |
|
|
|
|
|
|
|
msg_ok "Completed successfully!" |
|
|
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" |
|
|
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}" |
|
|
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:11434${CL}" |