Skip to content

Commit

Permalink
add install script for ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
ltdrdata committed May 11, 2024
1 parent 7ba4f16 commit 652a2ea
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions scripts/install-comfy-cli-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash
# Flag to track if apt-get update has been run
update_flag=false

# Check if ~/comfy directory exists, create it if not
if [ ! -d $(pwd)/comfy ]; then
mkdir $(pwd)/comfy
fi

echo "[1/6] CHECK: python3"
# Check if Python3 is installed
if ! command -v python3 &> /dev/null
then
echo "Python3 is not installed. Starting installation..."
if [ $(id -u) -eq 0 ] # Check if running as root
then
apt-get update
apt-get install -y python3
else
sudo apt-get update
sudo apt-get install -y python3
fi

update_flag=true
fi

echo "[2/6] CHECK: python3-venv"
# Check if Python venv is installed
python3 -m venv --help &> /dev/null
if [ $? -ne 0 ]
then
echo "Python3-venv is not installed. Starting installation..."
if [ "$update_flag" == false ]
then
if [ $(id -u) -eq 0 ] # Check if running as root
then
apt-get update
else
sudo apt-get update
fi

update_flag=true
fi
if [ $(id -u) -eq 0 ] # Check if running as root
then
apt-get install -y python3-venv
else
sudo apt-get install -y python3-venv
fi
fi

echo "[3/6] CHECK: git"
# Check if Git is installed
if ! command -v git &> /dev/null
then
echo "Git is not installed. Starting installation..."
if [ "$update_flag" == false ]
then
if [ $(id -u) -eq 0 ] # Check if running as root
then
apt-get update
else
sudo apt-get update
fi

update_flag=true
fi

if [ $(id -u) -eq 0 ] # Check if running as root
then
apt-get install -y git
else
sudo apt-get install -y git
fi
fi

echo "[4/6] CREATE: venv (~/comfy/venv)"
# Create virtual environment
if [ ! -d $(pwd)/comfy/venv ]
then
echo "Creating Python virtual environment..."
python3 -m venv $(pwd)/comfy/venv
fi

echo "[5/6] INSTALL: comfy-cli into venv"
# Install Comfy-CLI
echo "Installing Comfy-CLI..."
source $(pwd)/comfy/venv/bin/activate
pip install comfy-cli

echo "[6/6] INSTALL: ComfyUI into $(pwd)/comfy/ComfyUI"
# Run comfy install
echo "Running comfy install..."
comfy install

echo "[7/7] CREATE: Script for 'comfy launch'"
if [ ! -f $(pwd)/comfy/run.sh ]
then
echo "source $(pwd)/comfy/venv/bin/activate" > $(pwd)/comfy/run.sh
echo "comfy launch" >> $(pwd)/comfy/run.sh
chmod +x $(pwd)/comfy/run.sh
else
echo "Script file already exists: ~/comfy/run.sh"
fi

# Print virtual environment path
echo "==========================================================="
echo "Virtual environment path: $(pwd)/comfy/venv"
echo "ComfyUI path: $(pwd)/comfy/ComfyUI"
echo "Default launch script path: $(pwd)/comfy/run.sh"
echo "DONE."

0 comments on commit 652a2ea

Please sign in to comment.