adbrasi commited on
Commit
4de63d5
·
verified ·
1 Parent(s): 2edd213

Upload causvid_installer.sh

Browse files
Files changed (1) hide show
  1. causvid_installer.sh +220 -0
causvid_installer.sh ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # CausVid ComfyUI Installer
4
+ # Simple installer for CausVid workflow without model downloads
5
+
6
+ set -e
7
+ set -o pipefail
8
+
9
+ # ============================================================================
10
+ # GLOBAL CONFIGURATIONS
11
+ # ============================================================================
12
+
13
+ readonly WORKFLOW_URL="https://huggingface.co/adbrasi/testedownload/resolve/main/CausVid-WAN-14B-Flow.json"
14
+ readonly WORKSPACE_DIR="/workspace/ComfyUI"
15
+ readonly WORKFLOW_FILE="/workspace/CausVid-WAN-14B-Flow.json"
16
+
17
+ # ============================================================================
18
+ # UTILITY FUNCTIONS
19
+ # ============================================================================
20
+
21
+ log_info() {
22
+ echo "INFO: $1" >&2
23
+ }
24
+
25
+ log_warning() {
26
+ echo "WARNING: $1" >&2
27
+ }
28
+
29
+ log_error() {
30
+ echo "ERROR: $1" >&2
31
+ }
32
+
33
+ command_exists() {
34
+ command -v "$1" >/dev/null 2>&1
35
+ }
36
+
37
+ # ============================================================================
38
+ # CLEANUP FUNCTION
39
+ # ============================================================================
40
+
41
+ cleanup_existing_installation() {
42
+ log_info "Checking for existing installations..."
43
+
44
+ if [ -d "$WORKSPACE_DIR" ]; then
45
+ log_warning "Found existing directory: $WORKSPACE_DIR"
46
+ log_info "Removing existing installation to avoid conflicts..."
47
+ rm -rf "$WORKSPACE_DIR"
48
+ fi
49
+
50
+ # Also clean up any potential leftover directories
51
+ if [ -d "/workspace/ComfyUi" ]; then
52
+ log_info "Removing /workspace/ComfyUi..."
53
+ rm -rf "/workspace/ComfyUi"
54
+ fi
55
+
56
+ if [ -d "/workspace/comfyui" ]; then
57
+ log_info "Removing /workspace/comfyui..."
58
+ rm -rf "/workspace/comfyui"
59
+ fi
60
+ }
61
+
62
+ # ============================================================================
63
+ # COMFY-CLI INSTALLATION
64
+ # ============================================================================
65
+
66
+ install_comfy_cli() {
67
+ log_info "Installing/upgrading comfy-cli..."
68
+
69
+ python3 -m pip install --upgrade comfy-cli || {
70
+ log_error "Failed to install comfy-cli"
71
+ exit 1
72
+ }
73
+
74
+ # Check if comfy is in PATH
75
+ if ! command_exists comfy; then
76
+ if [ -d "$HOME/.local/bin" ]; then
77
+ export PATH="$HOME/.local/bin:$PATH"
78
+ log_info "Added $HOME/.local/bin to PATH"
79
+ fi
80
+
81
+ if ! command_exists comfy; then
82
+ log_error "comfy command not found in PATH after installation"
83
+ exit 1
84
+ fi
85
+ fi
86
+
87
+ log_info "comfy-cli version: $(comfy --version 2>/dev/null || echo 'unknown')"
88
+ }
89
+
90
+ # ============================================================================
91
+ # COMFYUI INSTALLATION
92
+ # ============================================================================
93
+
94
+ install_comfyui() {
95
+ log_info "Installing ComfyUI to $WORKSPACE_DIR..."
96
+
97
+ # Ensure parent directory exists
98
+ mkdir -p "$(dirname "$WORKSPACE_DIR")"
99
+
100
+ # Install ComfyUI with fast dependencies
101
+ comfy --workspace "$WORKSPACE_DIR" --skip-prompt install --nvidia --fast-deps || {
102
+ log_error "Failed to install ComfyUI"
103
+ exit 1
104
+ }
105
+
106
+ log_info "ComfyUI installed successfully"
107
+ }
108
+
109
+ # ============================================================================
110
+ # WORKFLOW DOWNLOAD
111
+ # ============================================================================
112
+
113
+ download_workflow() {
114
+ log_info "Downloading CausVid workflow..."
115
+
116
+ local success=false
117
+
118
+ # Try different download methods
119
+ if command_exists wget; then
120
+ if wget -q --show-progress -O "$WORKFLOW_FILE" "$WORKFLOW_URL"; then
121
+ success=true
122
+ fi
123
+ elif command_exists curl; then
124
+ if curl -L -o "$WORKFLOW_FILE" "$WORKFLOW_URL"; then
125
+ success=true
126
+ fi
127
+ elif command_exists aria2c; then
128
+ if aria2c -q -o "$(basename "$WORKFLOW_FILE")" -d "$(dirname "$WORKFLOW_FILE")" "$WORKFLOW_URL"; then
129
+ success=true
130
+ fi
131
+ else
132
+ log_error "No download tool available (wget, curl, or aria2c)"
133
+ exit 1
134
+ fi
135
+
136
+ if ! $success; then
137
+ log_error "Failed to download workflow file"
138
+ exit 1
139
+ fi
140
+
141
+ if [ ! -f "$WORKFLOW_FILE" ]; then
142
+ log_error "Workflow file was not downloaded successfully"
143
+ exit 1
144
+ fi
145
+
146
+ log_info "Workflow downloaded to: $WORKFLOW_FILE"
147
+ }
148
+
149
+ # ============================================================================
150
+ # WORKFLOW DEPENDENCIES
151
+ # ============================================================================
152
+
153
+ install_workflow_dependencies() {
154
+ log_info "Installing workflow dependencies..."
155
+
156
+ if [ ! -f "$WORKFLOW_FILE" ]; then
157
+ log_error "Workflow file not found: $WORKFLOW_FILE"
158
+ exit 1
159
+ fi
160
+
161
+ comfy node install-deps --workflow="$WORKFLOW_FILE" || {
162
+ log_warning "Some workflow dependencies may have failed to install"
163
+ log_info "This is often normal - ComfyUI will show missing nodes on startup"
164
+ }
165
+
166
+ log_info "Workflow dependencies installation completed"
167
+ }
168
+
169
+ # ============================================================================
170
+ # LAUNCH COMFYUI
171
+ # ============================================================================
172
+
173
+ launch_comfyui() {
174
+ log_info "Launching ComfyUI on port 8818..."
175
+ log_info "ComfyUI will be accessible at: http://0.0.0.0:8818"
176
+ log_info "Workflow file is available at: $WORKFLOW_FILE"
177
+
178
+ # Launch ComfyUI
179
+ exec comfy --workspace "$WORKSPACE_DIR" launch -- --fast --listen 0.0.0.0 --port 8818
180
+ }
181
+
182
+ # ============================================================================
183
+ # MAIN EXECUTION
184
+ # ============================================================================
185
+
186
+ main() {
187
+ log_info "Starting CausVid ComfyUI installation..."
188
+ log_info "======================================"
189
+
190
+ # Step 1: Clean up any existing installations
191
+ cleanup_existing_installation
192
+
193
+ # Step 2: Install comfy-cli
194
+ install_comfy_cli
195
+
196
+ # Step 3: Install ComfyUI
197
+ install_comfyui
198
+
199
+ # Step 4: Download workflow
200
+ download_workflow
201
+
202
+ # Step 5: Install workflow dependencies
203
+ install_workflow_dependencies
204
+
205
+ # Step 6: Launch ComfyUI
206
+ log_info "======================================"
207
+ log_info "Installation completed successfully!"
208
+ log_info "======================================"
209
+ launch_comfyui
210
+ }
211
+
212
+ # ============================================================================
213
+ # SCRIPT EXECUTION
214
+ # ============================================================================
215
+
216
+ # Trap to handle script interruption
217
+ trap 'log_error "Script interrupted"; exit 1' INT TERM
218
+
219
+ # Run main function
220
+ main "$@"