flnxi-Wu/scripts/download-minio-mc.ps1
WuYongJie 8705b9846a
Some checks failed
CI Check / check (push) Has been cancelled
feat: 统一弹窗样式系统与分类管理优化
- 创建统一的Modal组件,采用Apple风格设计
- 实现毛玻璃效果、圆角、动画和细边框描边
- 修复弹窗打开时背景滚动问题
- 修复分类管理中重复卡片和数组字符串显示问题
- 优化选项解析逻辑,添加去重和过滤机制
2025-11-25 09:37:00 +08:00

99 lines
3.7 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# MinIO MC 镜像下载脚本
# 用于在本地下载 minio/mc 镜像并传输到服务器
param(
[string]$Server = "45.249.208.118",
[string]$Username = "root",
[string]$KeyPath = "C:\Users\Mr_Wu01\.ssh\youyidian_prod_ed25519",
[string]$ImageTag = "latest"
)
$ErrorActionPreference = "Stop"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " MinIO MC 镜像下载脚本" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# 1. 拉取镜像
Write-Host "[1/4] 拉取 minio/mc:$ImageTag 镜像..." -ForegroundColor Yellow
try {
docker pull "minio/mc:$ImageTag"
Write-Host "✓ 镜像拉取成功" -ForegroundColor Green
} catch {
Write-Host "✗ 镜像拉取失败: $_" -ForegroundColor Red
exit 1
}
# 2. 保存镜像
Write-Host ""
Write-Host "[2/4] 保存镜像到文件..." -ForegroundColor Yellow
$tarFile = "minio-mc-$ImageTag.tar"
$tarGzFile = "$tarFile.gz"
try {
docker save "minio/mc:$ImageTag" -o $tarFile
$fileSize = (Get-Item $tarFile).Length / 1MB
Write-Host "✓ 镜像已保存: $tarFile ($([math]::Round($fileSize, 2)) MB)" -ForegroundColor Green
# 压缩文件
Write-Host " 压缩镜像文件..." -ForegroundColor Gray
Compress-Archive -Path $tarFile -DestinationPath $tarGzFile -Force
$compressedSize = (Get-Item $tarGzFile).Length / 1MB
Write-Host "✓ 镜像已压缩: $tarGzFile ($([math]::Round($compressedSize, 2)) MB)" -ForegroundColor Green
Remove-Item $tarFile -ErrorAction SilentlyContinue
} catch {
Write-Host "✗ 镜像保存失败: $_" -ForegroundColor Red
exit 1
}
# 3. 传输到服务器
Write-Host ""
Write-Host "[3/4] 传输镜像到服务器..." -ForegroundColor Yellow
try {
$scpArgs = @("-i", $KeyPath, $tarGzFile, "${Username}@${Server}:/root/")
$scpProcess = Start-Process -FilePath "scp" -ArgumentList $scpArgs -NoNewWindow -PassThru -Wait
if ($scpProcess.ExitCode -eq 0) {
Write-Host "✓ 镜像传输成功" -ForegroundColor Green
} else {
Write-Host "✗ 镜像传输失败(退出码: $($scpProcess.ExitCode))" -ForegroundColor Red
exit 1
}
} catch {
Write-Host "✗ 镜像传输失败: $_" -ForegroundColor Red
exit 1
}
# 4. 在服务器上加载镜像
Write-Host ""
Write-Host "[4/4] 在服务器上加载镜像..." -ForegroundColor Yellow
try {
$sshArgs = @("-i", $KeyPath, "${Username}@${Server}", "cd /root && gunzip -c $tarGzFile > $tarFile && docker load -i $tarFile && rm -f $tarFile $tarGzFile && docker images | grep minio/mc")
$sshProcess = Start-Process -FilePath "ssh" -ArgumentList $sshArgs -NoNewWindow -PassThru -Wait
if ($sshProcess.ExitCode -eq 0) {
Write-Host "✓ 镜像加载成功" -ForegroundColor Green
} else {
Write-Host "✗ 镜像加载失败(退出码: $($sshProcess.ExitCode))" -ForegroundColor Red
exit 1
}
} catch {
Write-Host "✗ 镜像加载失败: $_" -ForegroundColor Red
exit 1
}
# 清理本地文件
Write-Host ""
Write-Host "清理本地临时文件..." -ForegroundColor Yellow
Remove-Item $tarFile -ErrorAction SilentlyContinue
Write-Host "✓ 清理完成" -ForegroundColor Green
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " 完成!MinIO MC 镜像已部署到服务器" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "现在可以启动 minio-init 服务:" -ForegroundColor Yellow
Write-Host " ssh -i $KeyPath ${Username}@${Server}" -ForegroundColor Gray
Write-Host " cd /root/deploy" -ForegroundColor Gray
Write-Host " docker-compose up -d minio-init" -ForegroundColor Gray