adbrasi commited on
Commit
fc08a6d
·
verified ·
1 Parent(s): ba93d77

Upload CesarkonPackreatorV1.sh

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