cd /news/generative-ai/provision-sh · home › topics › generative-ai › article
[ARTICLE · art-181724] src=gist.github.com ↗ pub= topic=generative-ai verified=true sentiment=· neutral

provision.sh

A developer published a bash provisioning script for Vast.ai that automates first-boot setup of a ComfyUI environment, cloning the ComfyUI repository, installing prebuilt llama-cpp-python and FlashAttention wheels, downloading a set of MiniMax-H3 models and LoRAs from Hugging Face, and pulling ten custom nodes. The script wraps installs and downloads in a three-attempt retry helper with 5- and 10-second backoff, falls back between uv and pip or hf commands, and records missing prerequisites such as the virtualenv or uv in a failures array.

recommendation

Pin prebuilt CUDA wheels and model URLs in a provisioning script and wrap each download or install in a retry with backoff so a single network failure doesn't leave a rented GPU half-configured.

more in playbook: Inference and self-hosting
by read6 min views4 publishedDec 4, 2026

| | #!/usr/bin/env bash | | | # Vast.ai ComfyUI first-boot provisioning script. | | | # Set PROVISIONING_SCRIPT to the public raw URL for this file. | | | set -uo pipefail |

|  | WORKSPACE="${WORKSPACE:-/workspace}" | 
|  | COMFYUI_DIR="${WORKSPACE}/ComfyUI" | 
|  | COMFYUI_REPO_URL="${COMFYUI_REPO_URL:-https://github.com/Comfy-Org/ComfyUI.git}" | 
|  | COMFYUI_BRANCH="${COMFYUI_BRANCH:-master}" | 
|  | MODELS_DIR="${COMFYUI_DIR}/models" | 

| | VENV_PYTHON="/venv/main/bin/python" |

|  | export HF_HUB_DOWNLOAD_TIMEOUT="${HF_HUB_DOWNLOAD_TIMEOUT:-60}" | 
|  | export HF_HUB_ETAG_TIMEOUT="${HF_HUB_ETAG_TIMEOUT:-30}" | 
|  | WHEEL_URLS=( | 
|  | "https://github.com/JamePeng/llama-cpp-python/releases/download/v0.3.49-cu131-linux-20260831/llama_cpp_python-0.3.49+cu131-cp312-cp312-linux_x86_64.whl" | 
|  | "https://github.com/mjun0812/flash-attention-prebuild-wheels/releases/download/v0.9.0/flash_attn-2.8.3+cu130torch2.10-cp312-cp312-linux_x86_64.whl" | 

| | ) | | | MODEL_DOWNLOADS=( | | | "hf://lightx2v/Minimax-h3-Turbo/minimax_h3_fl2v_turbo_8step_v1.0_comfyui_bf16.safetensors|loras" | | | "hf://Comfy-Org/MiniMax-H3/vae/minimax_h3_audio_vae_fp32.safetensors|vae" | | | "hf://Kijai/MiniMax-H3-experimental/minimax_h3_video_vae_int8_convrot.safetensors|vae" | | | "hf://Comfy-Org/MiniMax-H3/loras/minimax_h3_ref2v_turbo_4step_v0.1_comfyui_bf16.safetensors|loras" | | | "hf://Momoking/Qwen3-VL-32B-Heretic-MiniMax-H3-NVFP4/qwen3vl_32b_heretic_minimax_h3_nvfp4.safetensors|text_encoders" | | | "hf://Comfy-Org/MiniMax-H3/diffusion_models/minimax_h3_ref2va_int8_convrot.safetensors|diffusion_models" | | | "hf://TenStrip/10Eros-Max/10Eros_Max_h3_TURBO-hybrid_beta5_int8.safetensors|diffusion_models" | | | "hf://larryvrh/MiniMax-H3-Turbo-Lora/minimax_h3_turbo_v4_step600_ema.safetensors|loras" | | | ) | | | CUSTOM_NODES=( | | | "https://github.com/city96/ComfyUI-GGUF.git" | | | "https://github.com/rgthree/rgthree-comfy.git" | | | "https://github.com/pytraveler/MiniMax-H3-Prompt-Rewriter-ComfyUI.git" | | | "https://github.com/willmiao/ComfyUI-Lora-Manager.git" | | | "https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git" | | | "https://github.com/kijai/ComfyUI-KJNodes.git" | | | "https://github.com/yolain/ComfyUI-Easy-Use.git" | | | "https://github.com/Comfy-Org/Nvidia_RTX_Nodes_ComfyUI.git" | | | "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git" | | | "https://github.com/dreevelle/ComfyUI-ResolutionTools.git" | | | "https://github.com/vrgamegirl19/comfyui-vrgamedevgirl.git" | | | # "https://github.com/owner/ComfyUI-Custom-Node.git" | | | ) | | | failures=() | | | # Three attempts, with 5- and 10-second delays between failures. | | | retry() { | | | local attempt | | | for attempt in 1 2 3; do | | | if "$@"; then | | | return 0 | | | fi |

|  | if ((attempt < 3)); then | 
|  | echo "Warning: attempt ${attempt}/3 failed; retrying in $((attempt * 5)) seconds." | 
|  | sleep "$((attempt * 5))" | 

| | fi | | | done | | | return 1 | | | } | | | if [[ -f /venv/main/bin/activate ]]; then | | | # shellcheck disable=SC1091 | | | source /venv/main/bin/activate | | | else | | | echo "Warning: /venv/main/bin/activate was not found." | | | failures+=("main virtual environment") | | | fi |

|  | if command -v uv >/dev/null 2>&1; then | 
|  | HF_COMMAND=(uv tool run hf) | 
|  | elif command -v hf >/dev/null 2>&1; then | 

| | echo "Warning: uv was not found; using the existing hf command." |

|  | failures+=("uv") | 
|  | HF_COMMAND=(hf) | 

| | else | | | echo "Warning: neither uv nor hf was found; model downloads will fail." |

|  | failures+=("uv and hf") | 
|  | HF_COMMAND=(hf) | 

| | fi |

|  | if command -v uv >/dev/null 2>&1; then | 
|  | PIP_COMMAND=(uv pip install --python "${VENV_PYTHON}") | 

| | else | | | PIP_COMMAND=("${VENV_PYTHON}" -m pip install) | | | fi |

|  | echo "Updating ComfyUI to latest (${COMFYUI_BRANCH})..." | 
|  | COMFYUI_GIT=(git -c safe.directory='*' -C "${COMFYUI_DIR}") | 

| | comfyui_updated=false |

|  | if [[ -d "${COMFYUI_DIR}/.git" ]]; then | 
|  | if retry "${COMFYUI_GIT[@]}" fetch origin "+refs/heads/${COMFYUI_BRANCH}:refs/remotes/origin/${COMFYUI_BRANCH}" && \ | 
|  | "${COMFYUI_GIT[@]}" checkout -f -B "${COMFYUI_BRANCH}" "refs/remotes/origin/${COMFYUI_BRANCH}"; then | 

| | comfyui_updated=true | | | else |

|  | echo "Warning: failed to update ComfyUI in ${COMFYUI_DIR}; continuing." | 
|  | failures+=("ComfyUI update") | 

| | fi |

|  | elif [[ ! -e "${COMFYUI_DIR}" ]]; then | 
|  | if retry git clone --branch "${COMFYUI_BRANCH}" "${COMFYUI_REPO_URL}" "${COMFYUI_DIR}"; then | 

| | comfyui_updated=true | | | else | | | echo "Warning: failed to clone ComfyUI into ${COMFYUI_DIR}; continuing." | | | failures+=("ComfyUI clone") | | | fi | | | else | | | echo "Warning: ${COMFYUI_DIR} exists but is not a git repository; skipping ComfyUI update." | | | failures+=("ComfyUI update (not a git repo)") | | | fi |

|  | if [[ "${comfyui_updated}" == true ]]; then | 
|  | comfyui_commit="$("${COMFYUI_GIT[@]}" rev-parse --short HEAD 2>/dev/null \|\| true)" | 
|  | if [[ -n "${comfyui_commit}" ]]; then | 

| | echo "ComfyUI is now at ${comfyui_commit}." | | | fi | | | if [[ -f "${COMFYUI_DIR}/requirements.txt" ]]; then | | | echo "Installing ComfyUI requirements..." | | | if ! retry "${PIP_COMMAND[@]}" -r "${COMFYUI_DIR}/requirements.txt"; then | | | echo "Warning: failed to install ComfyUI requirements; continuing." | | | failures+=("ComfyUI requirements") | | | fi | | | fi |

|  | if [[ -f "${COMFYUI_DIR}/manager_requirements.txt" ]] && \ | 
|  | [[ -x "${VENV_PYTHON}" ]] && \ | 
|  | "${VENV_PYTHON}" -c "import importlib.metadata; importlib.metadata.version('comfyui-manager')" >/dev/null 2>&1; then | 

| | echo "Installing ComfyUI Manager requirements..." | | | if ! retry "${PIP_COMMAND[@]}" -r "${COMFYUI_DIR}/manager_requirements.txt"; then | | | echo "Warning: failed to install ComfyUI Manager requirements; continuing." | | | failures+=("ComfyUI Manager requirements") | | | fi | | | fi | | | fi |

|  | for entry in "${MODEL_DOWNLOADS[@]}"; do | 
|  | uri="${entry%%\|*}" | 
|  | model_subdir="${entry#*\|}" | 
|  | destination="${MODELS_DIR}/${model_subdir}" | 

| | # hf preserves repository paths. Avoid vae/vae, loras/loras, etc. |

|  | repo_path="${uri#hf://}" | 
|  | repo_path="${repo_path#*/}" | 
|  | repo_path="${repo_path#*/}" | 
|  | download_dir="${destination}" | 
|  | if [[ "${repo_path}" == "${model_subdir}/"* ]]; then | 
|  | download_dir="${MODELS_DIR}" | 

| | fi |

|  | if ! mkdir -p "${destination}"; then | 
|  | failures+=("${uri}: destination directory") | 

| | continue | | | fi |

|  | echo "Down ${uri} to ${destination}" | 
|  | if ! retry "${HF_COMMAND[@]}" download "${uri}" --local-dir "${download_dir}"; then | 

| | echo "Warning: download failed; continuing with the next model." | | | failures+=("${uri}") | | | fi | | | done | | | # Install prebuilt CUDA wheels before custom-node requirements so pip/uv | | | # does not try to compile packages like llama-cpp-python from source. | | | for wheel_url in "${WHEEL_URLS[@]}"; do | | | echo "Installing wheel ${wheel_url##/}" | | | if ! retry "${PIP_COMMAND[@]}" "${wheel_url}"; then | | | echo "Warning: wheel installation failed; continuing." | | | failures+=("${wheel_url##/}") | | | fi | | | done |

|  | CUSTOM_NODES_DIR="${COMFYUI_DIR}/custom_nodes" | 
|  | mkdir -p "${CUSTOM_NODES_DIR}" | 
|  | for repo_url in "${CUSTOM_NODES[@]}"; do | 
|  | node_name="${repo_url%/}" | 
|  | node_name="${node_name##*/}" | 
|  | node_name="${node_name%.git}" | 
|  | node_dir="${CUSTOM_NODES_DIR}/${node_name}" | 
|  | if [[ -d "${node_dir}/.git" ]]; then | 

| | echo "Custom node ${node_name} already exists; skipping clone." |

|  | elif ! retry git clone "${repo_url}" "${node_dir}"; then | 
|  | echo "Warning: failed to clone ${repo_url}; continuing." | 
|  | failures+=("${repo_url}") | 

| | continue | | | fi |

|  | node_requirements="${node_dir}/requirements.txt" | 
|  | if [[ -f "${node_requirements}" ]]; then | 

| | echo "Installing requirements for ${node_name}..." | | | if ! retry "${PIP_COMMAND[@]}" -r "${node_requirements}"; then | | | echo "Warning: failed to install requirements for ${node_name}; continuing." | | | failures+=("${node_name} requirements") | | | fi | | | fi | | | done | | | if ((${#failures[@]} > 0)); then | | | echo |

|  | echo "Provisioning finished with ${#failures[@]} warning(s):" | 
|  | printf ' - %s\n' "${failures[@]}" | 

| | else | | | echo "Provisioning completed successfully." | | | fi | | | # Always succeed so one unavailable download or custom node does not stop setup. | | | exit 0 |

── more in #generative-ai 4 stories · sorted by recency
── more on @vast.ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/provision-sh] indexed:0 read:6min 2026-12-04 · —