fscan/pull_images.sh
ZacharyZcR c2b63a57e2 refactor: 修正包命名规范并修复编译问题
- 重命名 Common -> common,WebScan -> webscan,遵循 Go 包命名约定
- 修复模块路径大小写不匹配导致的编译错误
- 清理依赖项,优化 go.mod 文件
- 添加 Docker 测试环境配置文件
- 新增镜像拉取脚本以处理网络超时问题
- 成功编译生成 fscan v2.2.1 可执行文件

该修复解决了 Linux 系统下包名大小写敏感导致的模块解析失败问题。
2025-09-01 22:41:54 +00:00

123 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# Fscan 测试镜像拉取脚本
# 排除 IMAP、POP3、Modbus 相关镜像
echo "=== Fscan 测试镜像拉取开始 ==="
echo "排除服务: IMAP, POP3, Modbus"
echo ""
# 基础镜像列表
images=(
# 数据库服务
"mysql:latest"
"postgres:latest"
"mongo:latest"
"redis:5.0.1"
"mcr.microsoft.com/mssql/server:2022-latest"
"neo4j:4.4"
"memcached:latest"
"cassandra:3.11"
# Web服务
"tomcat:9.0-jdk8"
"container-registry.oracle.com/middleware/weblogic:12.2.1.4-dev"
# 搜索引擎
"docker.elastic.co/elasticsearch/elasticsearch:7.9.3"
# 消息队列
"rabbitmq:3-management"
"rmohr/activemq:5.15.9"
"bitnami/kafka:latest"
# 监控系统
"zabbix/zabbix-server-mysql:ubuntu-6.0.23"
"zabbix/zabbix-web-nginx-mysql:ubuntu-6.0.23"
# 目录服务
"osixia/openldap:1.5.0"
# 网络服务
"bogem/ftp"
"ubuntu:latest" # SSH, SMTP, SNMP, Rsync, VNC, Telnet
"ubuntu:20.04" # SSH, SMTP, SNMP, Rsync, VNC, Telnet
"busybox:latest" # Telnet
)
# 记录成功和失败的镜像
success_count=0
failed_images=()
total_images=${#images[@]}
echo "需要拉取 $total_images 个镜像"
echo ""
# 拉取镜像函数
pull_image() {
local image=$1
local current=$2
local total=$3
echo "[$current/$total] 拉取镜像: $image"
# 设置超时和重试
local max_retries=3
local retry=0
while [ $retry -lt $max_retries ]; do
if timeout 300 docker pull "$image"; then
echo "✓ 成功: $image"
((success_count++))
return 0
else
((retry++))
if [ $retry -lt $max_retries ]; then
echo "⚠ 重试 $retry/$max_retries: $image"
sleep 5
fi
fi
done
echo "✗ 失败: $image (超时或网络错误)"
failed_images+=("$image")
return 1
}
# 开始拉取
start_time=$(date +%s)
for i in "${!images[@]}"; do
current=$((i + 1))
pull_image "${images[$i]}" "$current" "$total_images"
echo ""
done
# 统计结果
end_time=$(date +%s)
duration=$((end_time - start_time))
failed_count=${#failed_images[@]}
echo "=== 拉取完成 ==="
echo "总镜像数: $total_images"
echo "成功: $success_count"
echo "失败: $failed_count"
echo "用时: ${duration}s"
echo ""
# 显示失败的镜像
if [ $failed_count -gt 0 ]; then
echo "失败的镜像:"
for image in "${failed_images[@]}"; do
echo " - $image"
done
echo ""
echo "可以重新运行脚本来重试失败的镜像"
fi
# 检查 Docker 存储空间
echo "=== Docker 存储使用情况 ==="
docker system df
echo ""
echo "脚本执行完成!"