cd /workspace/madapps cat > install_comfyui.sh << 'EOF' #!/usr/bin/env bash #!/usr/bin/env bash # --------------------------------------------------------------------------- # ComfyUI one‑shot installer for RunPod (rev‑2) # --------------------------------------------------------------------------- # • Activates your virtualenv # • Installs official **system** CMake & tool‑chain first (avoids dlib build bug) # • Removes any pip‑provided cmake that might shadow /usr/bin/cmake # • Installs Python deps and downloads model weights (idempotent) # --------------------------------------------------------------------------- set -euo pipefail COMFY_DIR="${COMFY_DIR:-/workspace/madapps/ComfyUI}" VENV="${VENV:-$COMFY_DIR/.venv}" info() { echo -e "\033[1;32m[INFO]\033[0m $*"; } warn() { echo -e "\033[1;33m[WARN]\033[0m $*"; } # --------------------------------------------------------------------------- # Sanity checks # --------------------------------------------------------------------------- if [[ ! -d "$COMFY_DIR" ]]; then warn "ComfyUI directory '$COMFY_DIR' does not exist. Set COMFY_DIR or clone ComfyUI first."; exit 1; fi if [[ ! -d "$VENV" ]]; then warn "Python venv '$VENV' not found. Create it with 'python -m venv $VENV' first."; exit 1; fi # --------------------------------------------------------------------------- # Activate env & upgrade pip # --------------------------------------------------------------------------- info "Activating virtualenv…"; source "$VENV/bin/activate" info "Upgrading pip & wheel…"; pip install --upgrade pip wheel # --------------------------------------------------------------------------- # System build deps **first** so dlib finds a real /usr/bin/cmake # --------------------------------------------------------------------------- APT_CMD="apt-get"; [[ $(id -u) -ne 0 && $(command -v sudo) ]] && APT_CMD="sudo $APT_CMD" if [[ -n "$APT_CMD" ]]; then info "Installing system CMake & tool‑chain…" $APT_CMD update -y && $APT_CMD install -y cmake build-essential python3-dev git wget fi # --------------------------------------------------------------------------- # Ensure pip’s cmake, if present, doesn’t shadow the system one # --------------------------------------------------------------------------- if pip show cmake >/dev/null 2>&1; then warn "Removing pip‑installed cmake to avoid conflicts…"; pip uninstall -y cmake; fi # --------------------------------------------------------------------------- # Python packages that need the compiler tool‑chain # --------------------------------------------------------------------------- info "Installing Python deps (dlib, insightface)…" pip install --no-cache-dir dlib insightface info "Pinning transformers==4.52…" if pip show transformers >/dev/null 2>&1; then pip uninstall -y transformers; fi pip install --no-cache-dir transformers==4.52 # --------------------------------------------------------------------------- # Helper for installing/updating ComfyUI custom nodes # --------------------------------------------------------------------------- install_or_update_custom_node() { local name="$1" local repo_url="$2" # Derive a sane target directory from repo name (lowercased, minus .git) local repo_base="${repo_url##*/}" repo_base="${repo_base%.git}" local target_dir="$COMFY_DIR/custom_nodes/${repo_base,,}" info "Installing/Updating ${name} custom node…" if [[ -d "$target_dir/.git" ]]; then info "Updating existing ${name} repo…" git -C "$target_dir" pull --rebase --autostash else info "Cloning ${name} into custom_nodes…" git clone --depth 1 "$repo_url" "$target_dir" fi # If the repo uses submodules, fetch them if [[ -f "$target_dir/.gitmodules" ]]; then info "Updating git submodules for ${name}…" git -C "$target_dir" submodule update --init --recursive --depth 1 fi # Install Python requirements if present if [[ -f "$target_dir/requirements.txt" ]]; then info "Installing ${name} Python requirements…" pip install --no-cache-dir -r "$target_dir/requirements.txt" elif compgen -G "$target_dir/requirements*.txt" > /dev/null; then for req in "$target_dir"/requirements*.txt; do info "Installing ${name} Python requirements from $(basename "$req")…" pip install --no-cache-dir -r "$req" done fi # If it’s a Python package, install it (editable) as well if [[ -f "$target_dir/setup.py" || -f "$target_dir/pyproject.toml" ]]; then info "Installing ${name} as a Python package (editable)…" pip install --no-cache-dir -e "$target_dir" fi } # --------------------------------------------------------------------------- # Custom nodes: install/update # --------------------------------------------------------------------------- # (Optional) You can swap your existing Crystools block for this one-liner: install_or_update_custom_node "Crystools" "https://github.com/crystian/ComfyUI-Crystools.git" install_or_update_custom_node "Custom Scripts" "https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git" install_or_update_custom_node "KJ Nodes" "https://github.com/kijai/ComfyUI-KJNodes.git" install_or_update_custom_node "LayerStyle Advance" "https://github.com/chflame163/ComfyUI_LayerStyle_Advance.git" install_or_update_custom_node "Easy Use" "https://github.com/yolain/ComfyUI-Easy-Use.git" install_or_update_custom_node "ControlNet Aux" "https://github.com/Fannovel16/comfyui_controlnet_aux.git" install_or_update_custom_node "Essentials" "https://github.com/cubiq/ComfyUI_essentials.git" install_or_update_custom_node "Face Parsing" "https://github.com/Ryuukeisyou/comfyui_face_parsing.git" install_or_update_custom_node "Face Analysis" "https://github.com/cubiq/ComfyUI_FaceAnalysis.git" install_or_update_custom_node "ControlAltAI Nodes" "https://github.com/gseth/ControlAltAI-Nodes.git" install_or_update_custom_node "Masquerade Nodes" "https://github.com/BadCafeCode/masquerade-nodes-comfyui.git" install_or_update_custom_node "rgthree" "https://github.com/rgthree/rgthree-comfy.git" install_or_update_custom_node "WAS Node Suite" "https://github.com/WASasquatch/was-node-suite-comfyui.git" # --------------------------------------------------------------------------- # Helper for idempotent downloads # --------------------------------------------------------------------------- download() { local url="$1" dst="$2"; if [[ -f "$dst" ]]; then info "✓ $(basename "$dst") already exists"; else info "↓ $(basename "$dst")"; wget -q --show-progress -O "$dst" "$url"; fi } # Create dirs mkdir -p "$COMFY_DIR/models/"{checkpoints,unet,clip,vae,loras,controlnet} # --------------------------------------------------------------------------- # Model weights # --------------------------------------------------------------------------- info "Downloading model weights (skip if already present)…" # Checkpoint download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/lustifySDXLNSFW_oltFIXEDTEXTURES.safetensors?download=true" \ "$COMFY_DIR/models/checkpoints/lustifySDXLNSFW_oltFIXEDTEXTURES.safetensors" # UNet download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/flux1-dev-fp8.safetensors?download=true" \ "$COMFY_DIR/models/unet/flux1-dev-fp8.safetensors" download "https://huggingface.co/6chan/flux1-kontext-dev-fp8/resolve/main/flux1-kontext-dev-fp8-e4m3fn.safetensors?download=true" \ "$COMFY_DIR/models/unet/flux1-kontext-dev-fp8-e4m3fn.safetensors" download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/realDream_flux1V1.safetensors?download=true" \ "$COMFY_DIR/models/unet/realDream_flux1V1.safetensors" # CLIP download "https://huggingface.co/GraydientPlatformAPI/flux-clip/resolve/main/clip_l.safetensors?download=true" \ "$COMFY_DIR/models/clip/clip_l.safetensors" download "https://huggingface.co/GraydientPlatformAPI/flux-clip/resolve/main/t5xxl_fp8_e4m3fn.safetensors?download=true" \ "$COMFY_DIR/models/clip/t5xxl_fp8_e4m3fn.safetensors" # VAE download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/ae.safetensors?download=true" \ "$COMFY_DIR/models/vae/ae.safetensors" # Lora download "https://huggingface.co/XLabs-AI/flux-RealismLora/resolve/main/lora.safetensors?download=true" \ "$COMFY_DIR/models/loras/flux-RealismLora.safetensors" download "https://huggingface.co/stabletable25/lustifyxl/resolve/main/MysticXXX-v7.safetensors?download=true" \ "$COMFY_DIR/models/loras/MysticXXX-v7.safetensors" # ControlNet download "https://huggingface.co/jasperai/Flux.1-dev-Controlnet-Depth/resolve/main/diffusion_pytorch_model.safetensors?download=true" \ "$COMFY_DIR/models/controlnet/jasparaidepth.safetensors" download "https://huggingface.co/Shakker-Labs/FLUX.1-dev-ControlNet-Union-Pro-2.0/resolve/main/diffusion_pytorch_model.safetensors?download=true" \ "$COMFY_DIR/models/controlnet/controlnetunionpro2.safetensors" # --------------------------------------------------------------------------- info "✔ Setup finished. Launch ComfyUI with:\n cd $COMFY_DIR && bash run.sh" EOF chmod +x install_comfyui.sh