73e4fc005e
Server UI gains Update on stack cards, ComfyUI Models tab with workflow scan and downloads, and centralized comfyui_config. Model catalog and download scripts move from stacks/comfyui to server-ui so ComfyUI stays a minimal Docker wrapper for easier image updates.
53 lines
1.6 KiB
Bash
Executable File
53 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Shared HTTP download helpers for ComfyUI model scripts.
|
|
# shellcheck disable=SC2034
|
|
download_http_file() {
|
|
local url="$1"
|
|
local dest="$2"
|
|
local data_root="${DATA_ROOT:-/data}"
|
|
local dest_dir
|
|
dest_dir="$(dirname "${dest}")"
|
|
echo "Downloading ${url} ..."
|
|
echo "Target: ${dest}"
|
|
|
|
if [[ -w "${dest_dir}" ]]; then
|
|
if [[ -n "${HF_TOKEN:-}" ]]; then
|
|
if command -v wget >/dev/null 2>&1; then
|
|
wget -c --progress=dot:giga \
|
|
--header="Authorization: Bearer ${HF_TOKEN}" \
|
|
-O "${dest}" "${url}"
|
|
else
|
|
curl -fL -C - \
|
|
-H "Authorization: Bearer ${HF_TOKEN}" \
|
|
-o "${dest}" "${url}"
|
|
fi
|
|
else
|
|
if command -v wget >/dev/null 2>&1; then
|
|
wget -c --progress=dot:giga -O "${dest}" "${url}"
|
|
else
|
|
curl -fL -C - -o "${dest}" "${url}"
|
|
fi
|
|
fi
|
|
return
|
|
fi
|
|
|
|
if docker ps --format '{{.Names}}' 2>/dev/null | grep -qx 'comfyui'; then
|
|
local container_dest="/root/ComfyUI/models${dest#"${data_root}/apps/comfyui/models"}"
|
|
echo "Host directory not writable — using comfyui container: ${container_dest}"
|
|
if [[ -n "${HF_TOKEN:-}" ]]; then
|
|
docker exec comfyui wget -c --progress=dot:giga \
|
|
--header="Authorization: Bearer ${HF_TOKEN}" \
|
|
-O "${container_dest}" "${url}"
|
|
else
|
|
docker exec comfyui wget -c --progress=dot:giga \
|
|
-O "${container_dest}" "${url}"
|
|
fi
|
|
return
|
|
fi
|
|
|
|
echo "ERROR: Cannot write to ${dest_dir}"
|
|
echo "Fix: sudo chown -R \$USER:\$USER ${data_root}/apps/comfyui/models"
|
|
echo "Or start ComfyUI: cd stacks/comfyui && ./scripts/start.sh"
|
|
exit 1
|
|
}
|