From 652a2ea655a2d7305918fc5c7e12ffc6b81dde4c Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 11 May 2024 14:19:42 +0900 Subject: [PATCH 1/5] add install script for ubuntu --- scripts/install-comfy-cli-ubuntu.sh | 111 ++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 scripts/install-comfy-cli-ubuntu.sh diff --git a/scripts/install-comfy-cli-ubuntu.sh b/scripts/install-comfy-cli-ubuntu.sh new file mode 100755 index 00000000..d2014e8c --- /dev/null +++ b/scripts/install-comfy-cli-ubuntu.sh @@ -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." From 40d92c6390e58a4a3970f8c32e5164e639b878b9 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 11 May 2024 14:46:53 +0900 Subject: [PATCH 2/5] fix: python3-venv isn't detected properly --- scripts/install-comfy-cli-ubuntu.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/install-comfy-cli-ubuntu.sh b/scripts/install-comfy-cli-ubuntu.sh index d2014e8c..4d457f69 100755 --- a/scripts/install-comfy-cli-ubuntu.sh +++ b/scripts/install-comfy-cli-ubuntu.sh @@ -26,9 +26,7 @@ fi echo "[2/6] CHECK: python3-venv" # Check if Python venv is installed -python3 -m venv --help &> /dev/null -if [ $? -ne 0 ] -then +if ! dpkg -l | grep -qE 'python3\.[0-9]+-venv'; then echo "Python3-venv is not installed. Starting installation..." if [ "$update_flag" == false ] then From 4b4ddde70d667cbe72e3fb2880d778b733a62e32 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 11 May 2024 15:16:31 +0900 Subject: [PATCH 3/5] improve: allows extra args in run.sh script --- scripts/install-comfy-cli-ubuntu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-comfy-cli-ubuntu.sh b/scripts/install-comfy-cli-ubuntu.sh index 4d457f69..01830e82 100755 --- a/scripts/install-comfy-cli-ubuntu.sh +++ b/scripts/install-comfy-cli-ubuntu.sh @@ -95,7 +95,7 @@ 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 + echo "comfy launch -- $*" >> $(pwd)/comfy/run.sh chmod +x $(pwd)/comfy/run.sh else echo "Script file already exists: ~/comfy/run.sh" From 66efb906ae6209282383d0939b02ce6dde247b71 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 11 May 2024 15:55:40 +0900 Subject: [PATCH 4/5] fix: missing $* in generated run.sh add: install-comfy-cli-redhat.sh --- scripts/install-comfy-cli-redhat.sh | 81 +++++++++++++++++++++++++++++ scripts/install-comfy-cli-ubuntu.sh | 14 ++--- 2 files changed, 88 insertions(+), 7 deletions(-) create mode 100755 scripts/install-comfy-cli-redhat.sh diff --git a/scripts/install-comfy-cli-redhat.sh b/scripts/install-comfy-cli-redhat.sh new file mode 100755 index 00000000..ca2e6931 --- /dev/null +++ b/scripts/install-comfy-cli-redhat.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# Flag to track if yum 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 ]; then # Check if running as root + yum update -y + yum install -y python3 + else + sudo yum update -y + sudo yum install -y python3 + fi + update_flag=true +fi + +echo "[2/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 ]; then # Check if running as root + yum update -y + else + sudo yum update -y + fi + update_flag=true + fi + if [ "$(id -u)" -eq 0 ]; then # Check if running as root + yum install -y git-core + else + sudo yum install -y git-core + fi +fi + +echo "[3/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 "[4/6] INSTALL: comfy-cli into venv" + +# Install Comfy-CLI +echo "Installing Comfy-CLI..." +source "$(pwd)/comfy/venv/bin/activate" +pip install comfy-cli + +echo "[5/6] INSTALL: ComfyUI into $(pwd)/comfy/ComfyUI" + +# Run comfy install +echo "Running comfy install..." +comfy install + +echo "[6/6] 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." \ No newline at end of file diff --git a/scripts/install-comfy-cli-ubuntu.sh b/scripts/install-comfy-cli-ubuntu.sh index 01830e82..b492cda3 100755 --- a/scripts/install-comfy-cli-ubuntu.sh +++ b/scripts/install-comfy-cli-ubuntu.sh @@ -7,7 +7,7 @@ if [ ! -d $(pwd)/comfy ]; then mkdir $(pwd)/comfy fi -echo "[1/6] CHECK: python3" +echo "[1/7] CHECK: python3" # Check if Python3 is installed if ! command -v python3 &> /dev/null then @@ -24,7 +24,7 @@ then update_flag=true fi -echo "[2/6] CHECK: python3-venv" +echo "[2/7] CHECK: python3-venv" # Check if Python venv is installed if ! dpkg -l | grep -qE 'python3\.[0-9]+-venv'; then echo "Python3-venv is not installed. Starting installation..." @@ -47,7 +47,7 @@ if ! dpkg -l | grep -qE 'python3\.[0-9]+-venv'; then fi fi -echo "[3/6] CHECK: git" +echo "[3/7] CHECK: git" # Check if Git is installed if ! command -v git &> /dev/null then @@ -72,7 +72,7 @@ then fi fi -echo "[4/6] CREATE: venv (~/comfy/venv)" +echo "[4/7] CREATE: venv (~/comfy/venv)" # Create virtual environment if [ ! -d $(pwd)/comfy/venv ] then @@ -80,13 +80,13 @@ then python3 -m venv $(pwd)/comfy/venv fi -echo "[5/6] INSTALL: comfy-cli into venv" +echo "[5/7] 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" +echo "[6/7] INSTALL: ComfyUI into $(pwd)/comfy/ComfyUI" # Run comfy install echo "Running comfy install..." comfy install @@ -95,7 +95,7 @@ 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 + echo "comfy launch -- \$*" >> $(pwd)/comfy/run.sh chmod +x $(pwd)/comfy/run.sh else echo "Script file already exists: ~/comfy/run.sh" From 9dadfc42e1bada181d6d9c4750a7eb13b421d8b5 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sun, 12 May 2024 23:44:58 +0900 Subject: [PATCH 5/5] add --install-completion --- scripts/install-comfy-cli-redhat.sh | 1 + scripts/install-comfy-cli-ubuntu.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/install-comfy-cli-redhat.sh b/scripts/install-comfy-cli-redhat.sh index ca2e6931..c3de414a 100755 --- a/scripts/install-comfy-cli-redhat.sh +++ b/scripts/install-comfy-cli-redhat.sh @@ -57,6 +57,7 @@ echo "[4/6] INSTALL: comfy-cli into venv" echo "Installing Comfy-CLI..." source "$(pwd)/comfy/venv/bin/activate" pip install comfy-cli +comfy --install-completion echo "[5/6] INSTALL: ComfyUI into $(pwd)/comfy/ComfyUI" diff --git a/scripts/install-comfy-cli-ubuntu.sh b/scripts/install-comfy-cli-ubuntu.sh index b492cda3..927a87f1 100755 --- a/scripts/install-comfy-cli-ubuntu.sh +++ b/scripts/install-comfy-cli-ubuntu.sh @@ -85,6 +85,7 @@ echo "[5/7] INSTALL: comfy-cli into venv" echo "Installing Comfy-CLI..." source $(pwd)/comfy/venv/bin/activate pip install comfy-cli +comfy --install-completion echo "[6/7] INSTALL: ComfyUI into $(pwd)/comfy/ComfyUI" # Run comfy install