Comfyui / start.sh
newturok's picture
Update start.sh
0057964 verified
raw
history blame
2.32 kB
#!/bin/bash
echo "pod started"
if [[ $PUBLIC_KEY ]]
then
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cd ~/.ssh
echo $PUBLIC_KEY >> authorized_keys
chmod 700 -R ~/.ssh
cd /
service ssh start
fi
#!/bin/bash
if [[ -z "${HF_TOKEN}" ]] || [[ "${HF_TOKEN}" == "enter_your_huggingface_token_here" ]]
then
echo "HF_TOKEN is not set"
else
echo "HF_TOKEN is set, logging in..."
huggingface-cli login --token ${HF_TOKEN}
fi
# Start nginx as reverse proxy to enable api access
service nginx start
# Start JupyterLab
jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.allow_origin='*' --NotebookApp.token='' &
echo "JupyterLab started"
# Check if there is a venv directory, if so, activate it
if [ -d "/workspace/venv" ]; then
echo "venv directory found, activating it"
source /workspace/venv/bin/activate
fi
# RUN COMFYUI
python3 /workspace/ComfyUI/main.py --listen
# Function to download a file if it doesn't exist
download_file() {
local url=$1
local target_dir=$2
local target_file=$3
if [ ! -f "${target_file}" ]; then
echo "Downloading ${target_file}..."
mkdir -p "${target_dir}"
wget -O "${target_file}" "${url}" --progress=bar:force:noscroll
else
echo "${target_file} already exists, skipping download."
fi
}
# VAE model
download_file "https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.sft?download=true" \
"/ComfyUI/models/vae" \
"/ComfyUI/models/vae/ae.sft"
# Diffusion model
download_file "https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/flux1-dev.sft?download=true" \
"/ComfyUI/models/diffusion_models" \
"/ComfyUI/models/diffusion_models/flux1-dev.sft"
# CLIP models
download_file "https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors?download=true" \
"/ComfyUI/models/clip" \
"/ComfyUI/models/clip/clip_l.safetensors"
download_file "https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors?download=true" \
"/ComfyUI/models/clip" \
"/ComfyUI/models/clip/t5xxl_fp8_e4m3fn.safetensors"
echo "All required files have been checked/Downloaded!"
sleep infinity