-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sh
executable file
·463 lines (406 loc) · 19.3 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
#!/bin/bash
# 该脚本用于生成 Dialog 界面所需的选项
# 生成插件列表
build_list() {
local point
local name
local describe
local count=1
local flag=0
local input_file=$1
local output_file=$2
while true; do
point=$(cat ${input_file} | awk 'NR=='${count}' {print $1}')
name=$(cat ${input_file} | awk 'NR=='${count}' {print $3}' | awk -F '/' '{print $NF}')
describe=$(cat ${input_file} | awk 'NR=='${count}' {print $5}')
if [[ -z "${point}" ]]; then
break
else
if [[ -z "$(echo ${point} | grep __term_sd_task_sys)" ]]; then
echo "${point} ${name} ${describe}" >> "${output_file}"
fi
fi
count=$(( count + 1 ))
done
}
# 生成模型列表
build_list_for_model() {
local input_file=$1
local output_file=$2
cat "${input_file}" | awk '{if ($NF!="") {print $1 " " $(NF-1) " " $NF} }' >> "${output_file}"
}
# 生成 Dialog 列表
build_dialog_list() {
local start_time=$(date +'%Y-%m-%d %H:%M:%S')
local start_time_seconds=$(date --date="${start_time}" +%s)
local input_file=$1
local output_file=$2
local end_time
local end_time_seconds
local time_span
if [[ -f "${output_file}" ]]; then
rm -f "${output_file}"
fi
echo ":: 生成 ${output_file} 中"
build_list "${input_file}" "${output_file}"
end_time=$(date +'%Y-%m-%d %H:%M:%S')
end_time_seconds=$(date --date="${end_time}" +%s)
time_span=$(( end_time_seconds - start_time_seconds )) # 计算相隔时间
echo ":: 完成, 用时: ${time_span} sec"
}
# 生成 SD WebUI 插件说明
build_dialog_list_sd_webui() {
local start_time=$(date +'%Y-%m-%d %H:%M:%S')
local start_time_seconds=$(date --date="${start_time}" +%s)
local input_file=$1
local output_file=$2
local cache_file="task/dialog_cache.sh"
local flag=0
local count=1
local end_time
local end_time_seconds
local time_span
if [[ -f "${output_file}" ]]; then
rm -f "${output_file}"
fi
echo ":: 生成 ${output_file} 中"
echo "Stable Diffusion WebUI 插件说明:" >> "${output_file}"
echo "注:" >> "${output_file}"
echo "1、有些插件因为年久失修,可能会出现兼容性问题。具体介绍请通过链接查看项目的说明" >> "${output_file}"
echo "2、在名称右上角标 * 的为安装时默认勾选的插件" >> "${output_file}"
while true; do
extension_url=$(cat "${input_file}" | awk 'NR=='${count}' {print $3}')
extension_name=$(cat "${input_file}" | awk 'NR=='${count}' {print $3}' | awk -F '/' '{print $NF}')
extension_description=$(cat "${input_file}" | awk 'NR=='${count}' {print $7}')
list_head=$(cat "${input_file}" | awk 'NR=='${count}' {print $1}')
normal_install_info=$([ "$(cat "${input_file}" | awk 'NR=='${count}' {print $5}')" = "ON" ] && echo "*")
if [[ -z "${list_head}" ]]; then
break
else
if [[ -z "$(grep __term_sd_task_sys <<< ${list_head})" ]]; then
echo "" >> "${output_file}"
echo "${count}、${extension_name}${normal_install_info}" >> "${output_file}"
echo "描述:${extension_description}" >> "${output_file}"
echo "链接:${extension_url}" >> "${output_file}"
fi
fi
count=$(( count + 1 ))
done
end_time=$(date +'%Y-%m-%d %H:%M:%S')
end_time_seconds=$(date --date="${end_time}" +%s)
time_span=$(( end_time_seconds - start_time_seconds )) # 计算相隔时间
echo ":: 完成, 用时: ${time_span} sec"
}
# 生成 ComfyUI 扩展说明
build_dialog_list_comfyui() {
local start_time=$(date +'%Y-%m-%d %H:%M:%S')
local start_time_seconds=$(date --date="${start_time}" +%s)
local input_file_1=$1
local input_file_2=$2
local output_file=$3
local count=1
local end_time
local end_time_seconds
local time_span
if [[ -f "${output_file}" ]]; then
rm -f "${output_file}"
fi
echo ":: 生成 ${output_file} 中"
echo "ComfyUI 插件 / 自定义节点说明:" >> "${output_file}"
echo "注:" >> "${output_file}"
echo "1、有些插件因为年久失修,可能会出现兼容性问题。具体介绍请通过链接查看项目的说明" >> "${output_file}"
echo "2、在名称右上角标 * 的为安装时默认勾选的插件" >> "${output_file}"
echo "" >> "${output_file}"
echo "插件:" >> "${output_file}"
while true; do
extension_url=$(cat "${input_file_1}" | awk 'NR=='${count}' {print $3}')
extension_name=$(cat "${input_file_1}" | awk 'NR=='${count}' {print $3}' | awk -F '/' '{print $NF}')
extension_description=$(cat "${input_file_1}" | awk 'NR=='${count}' {print $7}')
list_head=$(cat "${input_file_1}" | awk 'NR=='${count}' {print $1}')
normal_install_info=$([ "$(cat "${input_file_1}" | awk 'NR=='${count}' {print $5}')" = "ON" ] && echo "*")
if [[ -z "${list_head}" ]]; then
break
else
if [ -z "$(echo "${list_head}" | grep __term_sd_task_sys)" ]; then
echo "" >> "${output_file}"
echo "${count}、${extension_name}${normal_install_info}" >> "${output_file}"
echo "描述:${extension_description}" >> "${output_file}"
echo "链接:${extension_url}" >> "${output_file}"
fi
fi
count=$(( count + 1 ))
done
echo "" >> "${output_file}"
echo "自定义节点:" >> "${output_file}"
count=1
while true; do
extension_url=$(cat "${input_file_2}" | awk 'NR=='${count}' {print $3}')
extension_name=$(cat "${input_file_2}" | awk 'NR=='${count}' {print $3}' | awk -F '/' '{print $NF}')
extension_description=$(cat "${input_file_2}" | awk 'NR=='${count}' {print $7}')
list_head=$(cat "${input_file_2}" | awk 'NR=='${count}' {print $1}')
normal_install_info=$([ "$(cat "${input_file_2}" | awk 'NR=='${count}' {print $5}')" = "ON" ] && echo "*")
if [[ -z "${list_head}" ]]; then
break
else
if [[ -z "$(echo "${list_head}" | grep __term_sd_task_sys)" ]]; then
echo "" >> "${output_file}"
echo "$count、${extension_name}${normal_install_info}" >> "${output_file}"
echo "描述:${extension_description}" >> "${output_file}"
echo "链接:${extension_url}" >> "${output_file}"
fi
fi
count=$(( count + 1 ))
done
end_time=$(date +'%Y-%m-%d %H:%M:%S')
end_time_seconds=$(date --date="${end_time}" +%s)
time_span=$(( end_time_seconds - start_time_seconds )) # 计算相隔时间
echo ":: 完成, 用时: ${time_span} sec"
}
# 生成 InvokeAI 自定义节点说明
build_dialog_list_invokeai() {
local start_time=$(date +'%Y-%m-%d %H:%M:%S')
local start_time_seconds=$(date --date="${start_time}" +%s)
local input_file=$1
local output_file=$2
local cache_file="task/dialog_cache.sh"
local flag=0
local count=1
local end_time
local end_time_seconds
local time_span
if [[ -f "${output_file}" ]]; then
rm -f "${output_file}"
fi
echo ":: 生成 ${output_file} 中"
echo "InvokeAI 自定义节点说明:" >> "${output_file}"
echo "注:" >> "${output_file}"
echo "1、有些插件因为年久失修,可能会出现兼容性问题。具体介绍请通过链接查看项目的说明" >> "${output_file}"
echo "2、在名称右上角标 * 的为安装时默认勾选的插件" >> "${output_file}"
while true; do
extension_url=$(cat "${input_file}" | awk 'NR=='${count}' {print $3}')
extension_name=$(cat "${input_file}" | awk 'NR=='${count}' {print $3}' | awk -F '/' '{print $NF}')
extension_description=$(cat "${input_file}" | awk 'NR=='${count}' {print $7}')
list_head=$(cat "${input_file}" | awk 'NR=='${count}' {print $1}')
normal_install_info=$([ "$(cat "${input_file}" | awk 'NR=='${count}' {print $5}')" = "ON" ] && echo "*")
if [[ -z "${list_head}" ]]; then
break
else
if [[ -z "$(grep __term_sd_task_sys <<< ${list_head})" ]]; then
echo "" >> "${output_file}"
echo "${count}、${extension_name}${normal_install_info}" >> "${output_file}"
echo "描述:${extension_description}" >> "${output_file}"
echo "链接:${extension_url}" >> "${output_file}"
fi
fi
count=$(( count + 1 ))
done
end_time=$(date +'%Y-%m-%d %H:%M:%S')
end_time_seconds=$(date --date="${end_time}" +%s)
time_span=$(( end_time_seconds - start_time_seconds )) # 计算相隔时间
echo ":: 完成, 用时: ${time_span} sec"
}
# 生成模型选择列表
build_dialog_list_model() {
local start_time=$(date +'%Y-%m-%d %H:%M:%S')
local start_time_seconds=$(date --date="${start_time}" +%s)
local input_file=$1
local output_file=$2
local end_time
local end_time_seconds
local time_span
if [[ -f "${output_file}" ]]; then
rm -f "${output_file}"
fi
echo ":: 生成 ${output_file} 中"
build_list_for_model "${input_file}" "${output_file}"
end_time=$(date +'%Y-%m-%d %H:%M:%S')
end_time_seconds=$(date --date="${end_time}" +%s)
time_span=$(( end_time_seconds - start_time_seconds )) # 计算相隔时间
echo ":: 完成, 用时: ${time_span} sec"
}
# 从列表截取命令
get_task_cmd() {
local task_cmd_sign
local task_cmd
task_cmd_sign=$(echo $@ | awk '{print $1}')
task_cmd=$(echo $@ | awk '{sub("'$task_cmd_sign' ","")}1')
echo "${task_cmd}"
}
# 重排序标签
sort_head_point() {
local cmd_sum
local cmd_point
local input_file=$2
local input_file_name=$(basename "${input_file}")
local start_time=$(date +'%Y-%m-%d %H:%M:%S')
local start_time_seconds=$(date --date="${start_time}" +%s)
local head_point=$1
local end_time
local end_time_seconds
local time_span
echo ":: 生成 ${input_file} 中"
mv "${input_file}" task/
cmd_sum=$(( $(cat "task/${input_file_name}" | wc -l) + 1)) # 统计命令行数
for (( cmd_point=1; cmd_point <= cmd_sum; cmd_point++ )); do
install_cmd=$(get_task_cmd $(cat "task/${input_file_name}" | awk 'NR=='${cmd_point}'{print $0}'))
if [[ ! -z "${install_cmd}" ]]; then
echo "${head_point}${cmd_point} ${install_cmd}" >> "${input_file}"
fi
done
rm "task/${input_file_name}"
end_time=$(date +'%Y-%m-%d %H:%M:%S')
end_time_seconds=$(date --date="${end_time}" +%s)
time_span=$(( end_time_seconds - start_time_seconds )) # 计算相隔时间
echo ":: 完成, 用时: ${time_span} sec"
}
# 链接查重
detect_uplicate() {
local list_type=$1
local file_path=$2
local cmd_sum=$(( $(cat "${file_path}" | wc -l) + 1)) # 统计命令行数
local start_time=$(date +'%Y-%m-%d %H:%M:%S')
local start_time_seconds=$(date --date="${start_time}" +%s)
local end_time
local end_time_seconds
local time_span
local flag=0
local install_cmd_1
local install_cmd_2
if [[ "${list_type}" == "model" ]]; then
list_column=3
type_name="模型链接"
elif [[ "${list_type}" == "extension" ]]; then
list_column=4
type_name="扩展链接"
fi
echo ":: 检测 $file_path 中重复的${type_name}中"
for ((i = 1; i <= cmd_sum; i++)); do
if [[ "${list_type}" == "model" ]]; then
install_cmd_1=$(cat "${file_path}" | awk 'NR=='${i}' { print $3 }')
elif [[ "${list_type}" == "extension" ]]; then
install_cmd_1=$(cat "${file_path}" | awk 'NR=='${i}' { print $4 }')
fi
for (( j = i; j <= cmd_sum; j++ )); do
[[ "${i}" = "${j}" ]] && continue
if [[ "${list_type}" == "model" ]]; then
install_cmd_2=$(cat "${file_path}" | awk 'NR=='${j}'{print $3}')
elif [[ "${list_type}" = "extension" ]]; then
install_cmd_2=$(cat "${file_path}" | awk 'NR=='${j}'{print $4}')
fi
if [[ "${install_cmd_1}" == "${install_cmd_2}" ]]; then
echo ":: 检测到重复${type_name}, 出现在第 ${i} 行和第 ${j} 行"
flag=1
fi
done
done
end_time=$(date +'%Y-%m-%d %H:%M:%S')
end_time_seconds=$(date --date="${end_time}" +%s)
time_span=$(( end_time_seconds - start_time_seconds )) # 计算相隔时间
if [[ "${flag}" == 0 ]]; then
echo ":: 无重复${type_name}"
else
echo ":: 出现重复${type_name}, 待解决"
fi
echo ":: 完成, 用时: ${time_span} sec"
}
#############################
if [[ ! -d "modules" ]] || [[ ! -d "install" ]] || [[ ! -d "task" ]] || [[ ! -d "help" ]]; then
echo ":: 目录错误"
exit 1
elif [[ ! "$(dirname "$0")" = "." ]]; then
echo ":: 目录错误"
exit 1
fi
if [[ ! -z "$@" ]]; then
echo "----------build----------"
start_time_sum=$(date +'%Y-%m-%d %H:%M:%S')
start_time_seconds_sum=$(date --date="$start_time_sum" +%s)
for n in $@ ;do
case "${n}" in
--fix)
echo ":: 格式转换"
list=$(find extra config help install modules task python_modules)
for i in ${list}; do
if [[ -f "${i}" ]]; then
dos2unix "${i}"
fi
done
dos2unix term-sd.sh
dos2unix build.sh
dos2unix README.md
;;
--build)
echo ":: 构建列表"
build_dialog_list install/sd_webui/sd_webui_extension.sh install/sd_webui/dialog_sd_webui_extension.sh
build_dialog_list install/comfyui/comfyui_custom_node.sh install/comfyui/dialog_comfyui_custom_node.sh
build_dialog_list install/comfyui/comfyui_extension.sh install/comfyui/dialog_comfyui_extension.sh
build_dialog_list install/invokeai/invokeai_custom_node.sh install/invokeai/dialog_invokeai_custom_node.sh
build_dialog_list_sd_webui install/sd_webui/sd_webui_extension.sh help/sd_webui_extension_description.md
build_dialog_list_comfyui install/comfyui/comfyui_extension.sh install/comfyui/comfyui_custom_node.sh help/comfyui_extension_description.md
build_dialog_list_invokeai install/invokeai/invokeai_custom_node.sh help/invokeai_custom_node_description.md
build_dialog_list_model install/sd_webui/sd_webui_hf_model.sh install/sd_webui/dialog_sd_webui_hf_model.sh
build_dialog_list_model install/sd_webui/sd_webui_ms_model.sh install/sd_webui/dialog_sd_webui_ms_model.sh
build_dialog_list_model install/comfyui/comfyui_hf_model.sh install/comfyui/dialog_comfyui_hf_model.sh
build_dialog_list_model install/comfyui/comfyui_ms_model.sh install/comfyui/dialog_comfyui_ms_model.sh
build_dialog_list_model install/fooocus/fooocus_hf_model.sh install/fooocus/dialog_fooocus_hf_model.sh
build_dialog_list_model install/fooocus/fooocus_ms_model.sh install/fooocus/dialog_fooocus_ms_model.sh
build_dialog_list_model install/invokeai/invokeai_hf_model.sh install/invokeai/dialog_invokeai_hf_model.sh
build_dialog_list_model install/invokeai/invokeai_ms_model.sh install/invokeai/dialog_invokeai_ms_model.sh
build_dialog_list_model install/lora_scripts/lora_scripts_hf_model.sh install/lora_scripts/dialog_lora_scripts_hf_model.sh
build_dialog_list_model install/lora_scripts/lora_scripts_ms_model.sh install/lora_scripts/dialog_lora_scripts_ms_model.sh
build_dialog_list_model install/kohya_ss/kohya_ss_hf_model.sh install/kohya_ss/dialog_kohya_ss_hf_model.sh
build_dialog_list_model install/kohya_ss/kohya_ss_ms_model.sh install/kohya_ss/dialog_kohya_ss_ms_model.sh
;;
--sort)
echo ":: 头标签排序"
sort_head_point __term_sd_task_pre_model_ install/sd_webui/sd_webui_hf_model.sh
sort_head_point __term_sd_task_pre_model_ install/sd_webui/sd_webui_ms_model.sh
sort_head_point __term_sd_task_pre_model_ install/comfyui/comfyui_hf_model.sh
sort_head_point __term_sd_task_pre_model_ install/comfyui/comfyui_ms_model.sh
sort_head_point __term_sd_task_pre_model_ install/fooocus/fooocus_hf_model.sh
sort_head_point __term_sd_task_pre_model_ install/fooocus/fooocus_ms_model.sh
sort_head_point __term_sd_task_pre_model_ install/invokeai/invokeai_hf_model.sh
sort_head_point __term_sd_task_pre_model_ install/invokeai/invokeai_ms_model.sh
sort_head_point __term_sd_task_pre_model_ install/lora_scripts/lora_scripts_hf_model.sh
sort_head_point __term_sd_task_pre_model_ install/lora_scripts/lora_scripts_ms_model.sh
sort_head_point __term_sd_task_pre_model_ install/kohya_ss/kohya_ss_hf_model.sh
sort_head_point __term_sd_task_pre_model_ install/kohya_ss/kohya_ss_ms_model.sh
sort_head_point __term_sd_task_pre_ext_ install/sd_webui/sd_webui_extension.sh
sort_head_point __term_sd_task_pre_ext_ install/comfyui/comfyui_custom_node.sh
sort_head_point __term_sd_task_pre_ext_ install/comfyui/comfyui_extension.sh
sort_head_point __term_sd_task_pre_ext_ install/invokeai/invokeai_custom_node.sh
;;
--check)
echo ":: 重复链接检测"
detect_uplicate model install/sd_webui/sd_webui_hf_model.sh
detect_uplicate model install/sd_webui/sd_webui_ms_model.sh
detect_uplicate model install/comfyui/comfyui_hf_model.sh
detect_uplicate model install/comfyui/comfyui_ms_model.sh
detect_uplicate model install/fooocus/fooocus_hf_model.sh
detect_uplicate model install/fooocus/fooocus_ms_model.sh
detect_uplicate model install/invokeai/invokeai_hf_model.sh
detect_uplicate model install/invokeai/invokeai_ms_model.sh
detect_uplicate model install/lora_scripts/lora_scripts_hf_model.sh
detect_uplicate model install/lora_scripts/lora_scripts_ms_model.sh
detect_uplicate model install/kohya_ss/kohya_ss_hf_model.sh
detect_uplicate model install/kohya_ss/kohya_ss_ms_model.sh
detect_uplicate extension install/sd_webui/sd_webui_extension.sh
detect_uplicate extension install/comfyui/comfyui_custom_node.sh
detect_uplicate extension install/comfyui/comfyui_extension.sh
detect_uplicate extension install/invokeai/invokeai_custom_node.sh
;;
*)
echo ":: 未知参数: \"${n}\""
;;
esac
done
echo "----------done----------"
end_time_sum=$(date +'%Y-%m-%d %H:%M:%S')
end_time_seconds_sum=$(date --date="${end_time_sum}" +%s)
time_span_sum=$(( end_time_seconds_sum - start_time_seconds_sum )) # 计算相隔时间
echo ":: 总共用时: ${time_span_sum} sec"
else
echo ":: 使用:"
echo "build.sh [--fix] [--build] [--sort] [--check]"
echo ":: 未指定操作"
fi