adbrasi commited on
Commit
0c158b5
·
verified ·
1 Parent(s): b65eae4

Upload CesarkonPackreatorV1.sh

Browse files
Files changed (1) hide show
  1. CesarkonPackreatorV1.sh +460 -0
CesarkonPackreatorV1.sh ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # ComfyUI Automated Setup Script
4
+ # Supports LightningAI, RunPod, VastAI, and generic Linux environments
5
+ # Author: Generated for automated ComfyUI deployment
6
+ # Modified based on user request.
7
+
8
+ set -e
9
+ set -o pipefail
10
+
11
+ # ============================================================================
12
+ # GLOBAL CONFIGURATIONS
13
+ # ============================================================================
14
+
15
+ # Civitai API Token
16
+ readonly CIVITAI_TOKEN="0b698de03658fb8df2eeef90bad3ab9a"
17
+
18
+ # Custom Nodes to Install (from Git, handled by comfy-cli)
19
+ readonly CUSTOM_NODES=(
20
+ "https://github.com/adbrasi/huggpackreator"
21
+ "https://github.com/adbrasi/packreator_processor"
22
+ "https://github.com/adbrasi/Packreator_manager"
23
+ "https://github.com/adbrasi/cezarsave34"
24
+ "https://github.com/adbrasi/pageonetor"
25
+ "https://github.com/adbrasi/pakreatorio"
26
+ "https://github.com/adbrasi/WaterMark_bumbumzin"
27
+ "https://github.com/adbrasi/marcadaguita"
28
+ "https://github.com/adbrasi/randomico"
29
+ "https://github.com/adbrasi/groqrouter"
30
+ "https://github.com/adbrasi/find_charakito"
31
+ "https://github.com/adbrasi/randomsizito"
32
+ "https://github.com/1038lab/ComfyUI-RMBG"
33
+ "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes"
34
+ "https://github.com/sipherxyz/comfyui-art-venture"
35
+ "https://github.com/pamparamm/sd-perturbed-attention"
36
+ "https://github.com/KoreTeknology/ComfyUI-Universal-Styler"
37
+ "https://github.com/WASasquatch/was-node-suite-comfyui"
38
+ "https://github.com/chflame163/ComfyUI_LayerStyle"
39
+ "https://github.com/ltdrdata/ComfyUI-Impact-Pack"
40
+ "https://github.com/pythongosssss/ComfyUI-Custom-Scripts"
41
+ "https://github.com/rgthree/rgthree-comfy"
42
+ "https://github.com/ssitu/ComfyUI_UltimateSDUpscale"
43
+
44
+ )
45
+
46
+ # Custom Nodes from Registry
47
+ readonly REGISTRY_NODES=(
48
+ "civicomfy"
49
+ "ComfyUI-RMBG"
50
+ )
51
+
52
+ # Files to Download - Format: "URL|target_subdir|filename"
53
+ readonly DOWNLOAD_FILES=(
54
+ "https://civitai.com/api/download/models/1761560?type=Model&format=SafeTensor&size=pruned&fp=fp16|checkpoints|"
55
+ "https://civitai.com/api/download/models/1410435?type=Model&format=SafeTensor&size=pruned&fp=fp16|checkpoints|"
56
+ "https://civitai.com/api/download/models/1268294?type=Model&format=SafeTensor|loras|"
57
+ "https://civitai.com/api/download/models/1715330?type=Model&format=SafeTensor|loras|"
58
+ "https://civitai.com/api/download/models/1499397?type=Model&format=SafeTensor|loras|"
59
+ "https://huggingface.co/Kim2091/AnimeSharp/resolve/main/4x-AnimeSharp.pth|upscale_models|4x-AnimeSharp.pth"
60
+ "https://huggingface.co/Kim2091/AnimeSharpV3/resolve/main/2x-AnimeSharpV3.pth|upscale_models|2x-AnimeSharpV3.pth"
61
+ "https://huggingface.co/adbrasi/testedownload/resolve/main/99coins_anime_girl_face_m_seg.pt|ultralytics/bbox|99coins_anime_girl_face_m_seg.pt"
62
+ )
63
+
64
+ # Model directories to create
65
+ readonly MODEL_DIRS=(
66
+ "checkpoints"
67
+ "loras"
68
+ "upscale_models"
69
+ "ultralytics/bbox"
70
+ "Nudenet" # ### NOVO ### Adicionado para garantir que a pasta exista
71
+ )
72
+
73
+ # Workflow configuration
74
+ readonly WORKFLOW_URL="https://huggingface.co/adbrasi/testedownload/resolve/main/packreator_setup.json"
75
+
76
+ # Global variables
77
+ BASE_DIR=""
78
+ COMFY_INSTALL_DIR=""
79
+ MODELS_DIR=""
80
+ WORKFLOW_FILE=""
81
+ SUDO_PREFIX=""
82
+ ARIA2C_AVAILABLE=false
83
+ ENV_NAME=""
84
+
85
+ # ============================================================================
86
+ # UTILITY FUNCTIONS
87
+ # ============================================================================
88
+
89
+ log_info() {
90
+ echo "INFO: $1" >&2
91
+ }
92
+
93
+ log_warning() {
94
+ echo "WARNING: $1" >&2
95
+ }
96
+
97
+ log_error() {
98
+ echo "ERROR: $1" >&2
99
+ }
100
+
101
+ command_exists() {
102
+ command -v "$1" >/dev/null 2>&1
103
+ }
104
+
105
+ is_root() {
106
+ [ "$(id -u)" -eq 0 ]
107
+ }
108
+
109
+ # ============================================================================
110
+ # ENVIRONMENT DETECTION
111
+ # ============================================================================
112
+
113
+ detect_environment() {
114
+ log_info "Detecting environment..."
115
+
116
+ if [ -d "/teamspace/studios/this_studio" ]; then
117
+ BASE_DIR="/teamspace/studios/this_studio"
118
+ ENV_NAME="lightning"
119
+ elif [ -d "/workspace" ] && [ ! -d "/teamspace/studios/this_studio" ]; then
120
+ BASE_DIR="/workspace"
121
+ ENV_NAME="runpod"
122
+ elif is_root && [ ! -d "/teamspace/studios/this_studio" ] && [ ! -d "/workspace" ]; then
123
+ BASE_DIR="/root"
124
+ ENV_NAME="vastai"
125
+ else
126
+ BASE_DIR="$HOME"
127
+ ENV_NAME="generic"
128
+ fi
129
+
130
+ COMFY_INSTALL_DIR="${BASE_DIR}/my_comfy_setup"
131
+ MODELS_DIR="${COMFY_INSTALL_DIR}/models"
132
+ WORKFLOW_FILE="${COMFY_INSTALL_DIR}/workflow.json"
133
+
134
+ log_info "Environment detected: $ENV_NAME"
135
+ log_info "Base directory: $BASE_DIR"
136
+ log_info "ComfyUI install directory: $COMFY_INSTALL_DIR"
137
+ log_info "Models directory: $MODELS_DIR"
138
+ }
139
+
140
+ # ============================================================================
141
+ # PERMISSION MANAGEMENT
142
+ # ============================================================================
143
+
144
+ setup_permissions() {
145
+ log_info "Setting up permissions..."
146
+
147
+ if is_root; then
148
+ SUDO_PREFIX=""
149
+ log_info "Running as root, no sudo needed"
150
+ elif command_exists sudo; then
151
+ SUDO_PREFIX="sudo "
152
+ log_info "Non-root user with sudo available"
153
+ else
154
+ SUDO_PREFIX=""
155
+ log_warning "Non-root user without sudo, some system operations may fail"
156
+ fi
157
+ }
158
+
159
+ # ============================================================================
160
+ # SYSTEM DEPENDENCIES
161
+ # ============================================================================
162
+
163
+ install_system_dependencies() {
164
+ log_info "Installing system dependencies..."
165
+
166
+ if command_exists apt-get; then
167
+ ${SUDO_PREFIX}apt-get update -qq || log_warning "Failed to update package list"
168
+ ${SUDO_PREFIX}apt-get install -y -qq python3 python3-pip git || { log_error "Failed to install basic dependencies (python3, pip, git)"; exit 1; }
169
+ if ${SUDO_PREFIX}apt-get install -y -qq aria2 >/dev/null 2>&1; then ARIA2C_AVAILABLE=true; log_info "aria2c installed successfully"; else ARIA2C_AVAILABLE=false; log_info "aria2c installation failed, will use wget/curl as fallback"; fi
170
+ else
171
+ log_warning "apt-get not available, skipping system package installation"
172
+ if command_exists aria2c; then ARIA2C_AVAILABLE=true; log_info "aria2c already available"; fi
173
+ fi
174
+ }
175
+
176
+ # ============================================================================
177
+ # COMFY-CLI INSTALLATION
178
+ # ============================================================================
179
+
180
+ install_comfy_cli() {
181
+ log_info "Installing comfy-cli..."
182
+
183
+ python3 -m pip install --upgrade comfy-cli || { log_error "Failed to install comfy-cli"; exit 1; }
184
+
185
+ if ! command_exists comfy; then
186
+ if [ -d "$HOME/.local/bin" ]; then export PATH="$HOME/.local/bin:$PATH"; log_info "Added $HOME/.local/bin to PATH"; fi
187
+ if ! command_exists comfy; then log_error "comfy command not found in PATH after installation"; exit 1; fi
188
+ fi
189
+
190
+ log_info "comfy-cli version: $(comfy --version 2>/dev/null || echo 'unknown')"
191
+ }
192
+
193
+ # ============================================================================
194
+ # COMFYUI CORE INSTALLATION
195
+ # ============================================================================
196
+
197
+ install_comfyui_core() {
198
+ log_info "Installing ComfyUI core..."
199
+ comfy --workspace "$COMFY_INSTALL_DIR" --skip-prompt install --nvidia || { log_error "Failed to install ComfyUI core"; exit 1; }
200
+ log_info "ComfyUI core installed successfully"
201
+ }
202
+
203
+ # ============================================================================
204
+ # DIRECTORY STRUCTURE
205
+ # ============================================================================
206
+
207
+ create_model_directories() {
208
+ log_info "Creating model directories..."
209
+ for dir in "${MODEL_DIRS[@]}"; do mkdir -p "$MODELS_DIR/$dir"; log_info "Created directory: $MODELS_DIR/$dir"; done
210
+ mkdir -p "$COMFY_INSTALL_DIR"
211
+ }
212
+
213
+ # ============================================================================
214
+ # CUSTOM NODES INSTALLATION
215
+ # ============================================================================
216
+
217
+ install_custom_nodes() {
218
+ log_info "Installing custom nodes..."
219
+
220
+ # Install nodes from registry
221
+ for node in "${REGISTRY_NODES[@]}"; do
222
+ log_info "Installing custom node from registry: $node"
223
+ comfy --workspace "$COMFY_INSTALL_DIR" node registry-install "$node" || { log_warning "Failed to install custom node from registry: $node"; }
224
+ done
225
+
226
+ # Install nodes from Git repositories
227
+ for node_url in "${CUSTOM_NODES[@]}"; do
228
+ log_info "Installing custom node from Git: $node_url"
229
+ comfy --workspace "$COMFY_INSTALL_DIR" node install "$node_url" || { log_warning "Failed to install custom node: $node_url"; }
230
+ done
231
+ }
232
+
233
+ # ============================================================================
234
+ # SPECIAL NODE: WD14 TAGGER (GIT CLONE METHOD)
235
+ # ============================================================================
236
+
237
+ install_wd14_tagger_node() {
238
+ log_info "Installing WD14 Tagger node via git clone..."
239
+ local node_repo="https://github.com/pythongosssss/ComfyUI-WD14-Tagger.git"
240
+ local node_name="ComfyUI-WD14-Tagger"
241
+ local custom_nodes_dir="${COMFY_INSTALL_DIR}/custom_nodes"
242
+ local target_dir="${custom_nodes_dir}/${node_name}"
243
+ local requirements_file="${target_dir}/requirements.txt"
244
+
245
+ # Ensure custom nodes directory exists
246
+ mkdir -p "$custom_nodes_dir"
247
+
248
+ if [ -d "$target_dir" ]; then
249
+ log_info "WD14 Tagger node already exists. Skipping clone."
250
+ else
251
+ log_info "Cloning WD14 Tagger repository into $target_dir"
252
+ if ! git clone "$node_repo" "$target_dir"; then
253
+ log_error "Failed to clone WD14 Tagger repository."
254
+ return 1
255
+ fi
256
+ fi
257
+
258
+ if [ -f "$requirements_file" ]; then
259
+ log_info "Installing WD14 Tagger dependencies from $requirements_file..."
260
+ if ! python3 -m pip install -r "$requirements_file"; then
261
+ log_warning "Failed to install WD14 Tagger dependencies. This might cause issues."
262
+ else
263
+ log_info "WD14 Tagger dependencies installed successfully."
264
+ fi
265
+ else
266
+ log_info "No requirements.txt found for WD14 Tagger. Skipping dependency installation."
267
+ fi
268
+ }
269
+
270
+ # ============================================================================
271
+ # SPECIAL NODE: STORY DIFFUSION
272
+ # ============================================================================
273
+
274
+ install_story_diffusion_node() {
275
+ log_info "Installing special node: StoryDiffusion..."
276
+ local node_repo="https://github.com/smthemex/ComfyUI_StoryDiffusion.git"
277
+ local node_name="ComfyUI_StoryDiffusion"
278
+ local custom_nodes_dir="${COMFY_INSTALL_DIR}/custom_nodes"
279
+ local target_dir="${custom_nodes_dir}/${node_name}"
280
+ local requirements_file="${target_dir}/requirements.txt"
281
+
282
+ # Garante que o diretório de nós customizados exista
283
+ mkdir -p "$custom_nodes_dir"
284
+
285
+ if [ -d "$target_dir" ]; then
286
+ log_info "StoryDiffusion node already exists. Skipping clone."
287
+ else
288
+ log_info "Cloning StoryDiffusion repository into $target_dir"
289
+ if ! git clone "$node_repo" "$target_dir"; then
290
+ log_error "Failed to clone StoryDiffusion repository."
291
+ # Continuar mesmo com falha, apenas avisar
292
+ return 1
293
+ fi
294
+ fi
295
+
296
+ if [ -f "$requirements_file" ]; then
297
+ log_info "Installing StoryDiffusion dependencies from $requirements_file..."
298
+ if ! python3 -m pip install -r "$requirements_file"; then
299
+ log_warning "Failed to install StoryDiffusion dependencies. This might cause issues."
300
+ else
301
+ log_info "StoryDiffusion dependencies installed successfully."
302
+ fi
303
+ else
304
+ log_info "No requirements.txt found for StoryDiffusion. Skipping dependency installation."
305
+ fi
306
+ }
307
+
308
+ # ============================================================================
309
+ # ### NOVO ### SPECIAL NODE: NUDENET
310
+ # ============================================================================
311
+
312
+ install_nudenet_node() {
313
+ log_info "Installing special node: NudeNet..."
314
+ local node_repo="https://github.com/phuvinh010701/ComfyUI-NudeNet.git"
315
+ local node_name="ComfyUI-NudeNet"
316
+ local custom_nodes_dir="${COMFY_INSTALL_DIR}/custom_nodes"
317
+ local target_dir="${custom_nodes_dir}/${node_name}"
318
+ local requirements_file="${target_dir}/requirements.txt"
319
+
320
+ # Etapa 1: Clonar o repositório se não existir
321
+ mkdir -p "$custom_nodes_dir"
322
+ if [ -d "$target_dir" ]; then
323
+ log_info "NudeNet node directory already exists. Skipping clone."
324
+ else
325
+ log_info "Cloning NudeNet repository into $target_dir"
326
+ if ! git clone "$node_repo" "$target_dir"; then
327
+ log_error "Failed to clone NudeNet repository."
328
+ return 1 # Abortar a instalação deste node específico
329
+ fi
330
+ fi
331
+
332
+ # Etapa 2: Instalar dependências do requirements.txt
333
+ if [ -f "$requirements_file" ]; then
334
+ log_info "Installing NudeNet dependencies from $requirements_file..."
335
+ if ! python3 -m pip install -r "$requirements_file"; then
336
+ log_warning "Failed to install NudeNet dependencies. This might cause issues."
337
+ else
338
+ log_info "NudeNet dependencies installed successfully."
339
+ fi
340
+ else
341
+ log_info "No requirements.txt found for NudeNet. Skipping dependency installation."
342
+ fi
343
+
344
+ # Etapa 3: Baixar o modelo .onnx para a pasta correta
345
+ log_info "Setting up NudeNet model..."
346
+ local nudenet_model_dir="${MODELS_DIR}/Nudenet"
347
+ local nudenet_model_url="https://d2xl8ijk56kv4u.cloudfront.net/models/nudenet.onnx"
348
+ local nudenet_model_filename="nudenet.onnx"
349
+ local nudenet_model_path="${nudenet_model_dir}/${nudenet_model_filename}"
350
+
351
+ mkdir -p "$nudenet_model_dir" # Garante que o diretório de destino exista
352
+
353
+ if [ -f "$nudenet_model_path" ]; then
354
+ log_info "NudeNet model already exists at $nudenet_model_path. Skipping download."
355
+ else
356
+ log_info "Downloading NudeNet model to $nudenet_model_path..."
357
+ if ! download_file "$nudenet_model_url" "$nudenet_model_dir" "$nudenet_model_filename"; then
358
+ log_error "Failed to download the NudeNet model. The node may not work correctly."
359
+ else
360
+ log_info "NudeNet model downloaded successfully."
361
+ fi
362
+ fi
363
+ }
364
+
365
+ # ============================================================================
366
+ # DOWNLOAD FUNCTIONS
367
+ # ============================================================================
368
+
369
+ add_civitai_token() { local url="$1"; if [[ "$url" == *"civitai.com/api/download"* ]] && [[ "$url" != *"token="* ]]; then echo "${url}&token=${CIVITAI_TOKEN}"; else echo "$url"; fi; }
370
+
371
+ download_file() {
372
+ local url="$1"; local target_dir="$2"; local filename="$3"; url=$(add_civitai_token "$url"); local download_cmd=""; local success=false
373
+ if $ARIA2C_AVAILABLE && command_exists aria2c; then local aria_opts="-c -s 16 -x 16 -k 1M --console-log-level=warn --summary-interval=0"; if [ -n "$filename" ]; then download_cmd="aria2c $aria_opts --dir=\"$target_dir\" --out=\"$filename\" \"$url\""; else download_cmd="aria2c $aria_opts --dir=\"$target_dir\" --content-disposition=true \"$url\""; fi; if eval "$download_cmd" >/dev/null 2>&1; then success=true; fi; fi
374
+ if ! $success && command_exists wget; then local wget_opts="-q --show-progress -c"; if [ -n "$filename" ]; then download_cmd="wget $wget_opts -O \"$target_dir/$filename\" \"$url\""; else download_cmd="wget $wget_opts --content-disposition -P \"$target_dir\" \"$url\""; fi; if eval "$download_cmd"; then success=true; fi; fi
375
+ if ! $success && command_exists curl; then log_warning "Using curl fallback for $url"; if [ -n "$filename" ]; then download_cmd="curl -L -C - -o \"$target_dir/$filename\" \"$url\""; else if curl --help 2>/dev/null | grep -q "output-dir"; then download_cmd="curl -L -J -O --output-dir \"$target_dir\" \"$url\""; else local fallback_name; fallback_name=$(basename "$url" | cut -d'?' -f1); [ -z "$fallback_name" ] && fallback_name="downloaded_file"; download_cmd="curl -L -C - -o \"$target_dir/$fallback_name\" \"$url\""; fi; fi; if eval "$download_cmd"; then success=true; fi; fi
376
+ if ! $success; then log_error "Failed to download: $url"; return 1; fi; return 0
377
+ }
378
+
379
+ # ============================================================================
380
+ # PARALLEL DOWNLOADS
381
+ # ============================================================================
382
+
383
+ download_all_files() {
384
+ log_info "Starting parallel downloads..."; local pids=(); local download_logs=()
385
+ for file_spec in "${DOWNLOAD_FILES[@]}"; do IFS='|' read -r url target_subdir filename <<< "$file_spec"; local target_dir="$MODELS_DIR/$target_subdir"; local display_name="${filename:-$(basename "$url" | cut -d'?' -f1)}"; log_info "Starting download: $display_name -> $target_dir"; local log_file; log_file=$(mktemp); download_logs+=("$log_file"); ( if download_file "$url" "$target_dir" "$filename" >"$log_file" 2>&1; then echo "SUCCESS: Downloaded $display_name" >> "$log_file"; else echo "FAILED: Failed to download $display_name" >> "$log_file"; exit 1; fi ) & pids+=($!); done
386
+ local failed_count=0; for i in "${!pids[@]}"; do if wait "${pids[$i]}"; then log_info "Download completed successfully"; else failed_count=$((failed_count + 1)); log_warning "Download failed - check logs"; fi; if [ -f "${download_logs[$i]}" ]; then cat "${download_logs[$i]}" >&2; rm -f "${download_logs[$i]}"; fi; done
387
+ if [ $failed_count -gt 0 ]; then log_warning "$failed_count downloads failed, but continuing..."; else log_info "All downloads completed successfully"; fi
388
+ }
389
+
390
+ # ============================================================================
391
+ # WORKFLOW DOWNLOAD
392
+ # ============================================================================
393
+
394
+ download_workflow() {
395
+ log_info "Baixando o workflow de: $WORKFLOW_URL"; log_info "Salvando como: $WORKFLOW_FILE"; local success=false
396
+ if command_exists wget; then if wget -q --show-progress -O "$WORKFLOW_FILE" "$WORKFLOW_URL"; then success=true; fi; fi
397
+ if ! $success && command_exists curl; then if curl -L -o "$WORKFLOW_FILE" "$WORKFLOW_URL"; then success=true; fi; fi
398
+ if ! $success && command_exists aria2c; then if aria2c -q -o "$(basename "$WORKFLOW_FILE")" -d "$(dirname "$WORKFLOW_FILE")" "$WORKFLOW_URL"; then success=true; fi; fi
399
+ if ! $success; then log_error "Nenhuma ferramenta de download (wget, curl, aria2c) funcionou ou está disponível."; exit 1; fi
400
+ if [ ! -f "$WORKFLOW_FILE" ]; then log_error "O arquivo do workflow não foi baixado com sucesso."; exit 1; fi; log_info "Workflow baixado com sucesso."
401
+ }
402
+
403
+ # ============================================================================
404
+ # WORKFLOW DEPENDENCIES
405
+ # ============================================================================
406
+
407
+ install_workflow_dependencies() {
408
+ log_info "Instalando dependências do workflow a partir de: $WORKFLOW_FILE"
409
+ if [ ! -f "$WORKFLOW_FILE" ]; then log_error "Arquivo de workflow não encontrado: $WORKFLOW_FILE"; return 1; fi
410
+ comfy --workspace "$COMFY_INSTALL_DIR" node install-deps --workflow="$WORKFLOW_FILE" || { log_warning "Algumas dependências do workflow podem ter falhado ao instalar."; log_info "Isso pode ser normal. O ComfyUI mostrará os nós ausentes ao iniciar."; }
411
+ log_info "Instalação de dependências do workflow concluída."
412
+ }
413
+
414
+ # ============================================================================
415
+ # COMFYUI LAUNCH
416
+ # ============================================================================
417
+
418
+ launch_comfyui() {
419
+ log_info "Launching ComfyUI on port 8818..."; log_info "ComfyUI will be accessible at: http://0.0.0.0:8818"
420
+ exec comfy --workspace "$COMFY_INSTALL_DIR" launch -- --fast --highvram --preview-method latent2rgb --listen 0.0.0.0 --port 8818
421
+ }
422
+
423
+ # ============================================================================
424
+ # MAIN EXECUTION
425
+ # ============================================================================
426
+
427
+ main() {
428
+ log_info "Starting ComfyUI automated setup..."
429
+ log_info "========================================"
430
+
431
+ detect_environment
432
+ setup_permissions
433
+ install_system_dependencies
434
+ install_comfy_cli
435
+ install_comfyui_core
436
+ create_model_directories
437
+ install_custom_nodes
438
+
439
+ # Install special nodes and their dependencies
440
+ install_wd14_tagger_node
441
+ install_story_diffusion_node
442
+ install_nudenet_node # ### NOVO ### Chamada para a nova função
443
+
444
+ download_all_files
445
+ download_workflow
446
+ install_workflow_dependencies
447
+
448
+ log_info "========================================"
449
+ log_info "Setup completed successfully!"
450
+ log_info "========================================"
451
+ launch_comfyui
452
+ }
453
+
454
+ # ============================================================================
455
+ # SCRIPT EXECUTION
456
+ # ============================================================================
457
+
458
+ trap 'log_error "Script interrupted"; exit 1' INT TERM
459
+
460
+ main "$@"