# iCloud 同步管理脚本 # 用法: .\icloud.ps1 <命令> # 命令: auth, logs, status, restart, sync param( [Parameter(Position=0)] [string]$Command ) $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path Set-Location $scriptDir if (-not $Command) { Write-Host "用法: .\icloud.ps1 <命令>" -ForegroundColor Cyan Write-Host "" Write-Host "命令:" -ForegroundColor Cyan Write-Host " auth - 重新认证" -ForegroundColor White Write-Host " logs - 查看实时日志" -ForegroundColor White Write-Host " status - 查看容器状态" -ForegroundColor White Write-Host " restart - 重启容器" -ForegroundColor White Write-Host " sync - 立即触发同步" -ForegroundColor White exit 0 } switch ($Command) { "auth" { Write-Host "开始 iCloud 认证..." -ForegroundColor Green Write-Host "请输入密码和验证码完成认证" -ForegroundColor Yellow docker exec -it icloudpd sync-icloud.sh --Initialise if ($LASTEXITCODE -eq 0) { Write-Host "认证成功!" -ForegroundColor Green } else { Write-Host "认证失败,请重试" -ForegroundColor Red } } "logs" { Write-Host "查看实时日志 (Ctrl+C 退出)..." -ForegroundColor Cyan docker logs -f icloudpd } "status" { docker ps --filter "name=icloudpd" --format "table {{.Status}}\t{{.Ports}}" docker logs --tail 10 icloudpd } "restart" { Write-Host "重启容器..." -ForegroundColor Yellow docker compose restart Write-Host "完成!" -ForegroundColor Green } "sync" { Write-Host "立即触发同步 (重启容器)..." -ForegroundColor Yellow docker restart icloudpd Write-Host "同步已触发,使用 '.\icloud.ps1 logs' 查看进度" -ForegroundColor Green } default { Write-Host "未知命令: $Command" -ForegroundColor Red Write-Host "" Write-Host "可用命令: auth, logs, status, restart, sync" -ForegroundColor Cyan } }