76 lines
2.1 KiB
Bash
76 lines
2.1 KiB
Bash
#!/bin/bash
|
|
|
|
echo "Creating directories for models..."
|
|
MODEL_DIRECTORIES=(
|
|
"checkpoints"
|
|
"clip"
|
|
"clip_vision"
|
|
"configs"
|
|
"controlnet"
|
|
"diffusers"
|
|
"diffusion_models"
|
|
"embeddings"
|
|
"gligen"
|
|
"hypernetworks"
|
|
"loras"
|
|
"photomaker"
|
|
"style_models"
|
|
"text_encoders"
|
|
"unet"
|
|
"upscale_models"
|
|
"vae"
|
|
"vae_approx"
|
|
)
|
|
|
|
for MODEL_DIRECTORY in ${MODEL_DIRECTORIES[@]};
|
|
do
|
|
mkdir -p /opt/comfyui/models/$MODEL_DIRECTORY
|
|
done
|
|
|
|
echo "Creating symlink for ComfyUI Manager..."
|
|
rm --force /opt/comfyui/custom_nodes/ComfyUI-Manager
|
|
ln -s \
|
|
/opt/comfyui-manager \
|
|
/opt/comfyui/custom_nodes/ComfyUI-Manager
|
|
|
|
echo "Installing requirements for custom nodes..."
|
|
for CUSTOM_NODE_DIRECTORY in /opt/comfyui/custom_nodes/*;
|
|
do
|
|
if [ "$CUSTOM_NODE_DIRECTORY" != "/opt/comfyui/custom_nodes/ComfyUI-Manager" ];
|
|
then
|
|
if [ -f "$CUSTOM_NODE_DIRECTORY/requirements.txt" ];
|
|
then
|
|
CUSTOM_NODE_NAME=${CUSTOM_NODE_DIRECTORY##*/}
|
|
CUSTOM_NODE_NAME=${CUSTOM_NODE_NAME//[-_]/ }
|
|
echo "Installing requirements for $CUSTOM_NODE_NAME..."
|
|
pip install --requirement "$CUSTOM_NODE_DIRECTORY/requirements.txt"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [ -z "$USER_ID" ] || [ -z "$GROUP_ID" ];
|
|
then
|
|
echo "Running container as $USER..."
|
|
exec /opt/conda/bin/python main.py \
|
|
--port 8188 \
|
|
--listen 0.0.0.0 \
|
|
--disable-auto-launch \
|
|
--enable-manager \
|
|
"$@"
|
|
else
|
|
echo "Creating non-root user..."
|
|
getent group $GROUP_ID > /dev/null 2>&1 || groupadd --gid $GROUP_ID comfyui-user
|
|
id -u $USER_ID > /dev/null 2>&1 || useradd --uid $USER_ID --gid $GROUP_ID --create-home comfyui-user
|
|
chown --recursive $USER_ID:$GROUP_ID /opt/comfyui
|
|
chown --recursive $USER_ID:$GROUP_ID /opt/comfyui-manager
|
|
export PATH=$PATH:/home/comfyui-user/.local/bin
|
|
|
|
echo "Running as comfyui-user..."
|
|
sudo --set-home --preserve-env=PATH --user \#$USER_ID \
|
|
/opt/conda/bin/python main.py \
|
|
--port 8188 \
|
|
--listen 0.0.0.0 \
|
|
--disable-auto-launch \
|
|
--enable-manager \
|
|
"$@"
|
|
fi |