- RemoteRoot 固定为 /wwwroot (IIS 站点物理根), 网页必须存放于 wwwroot 才可访问 - ftp_upload.ps1: 每文件独立连接、上传后校验大小、3次重试、日志记录 - 新增 ftp_fast.ps1 (快速覆盖上传) 与 ftp_sync.ps1 (仅补传缺失/大小不符文件) - 上传前删除服务商默认欢迎页 default.html, 避免优先于 index.html
32 lines
1.7 KiB
PowerShell
32 lines
1.7 KiB
PowerShell
# Minimal direct upload (no size check) - fast overwrite upload
|
|
$FtpHost="116.198.221.125"; $FtpUser="wenchuanyi"; $FtpPass="r7P^f*v7rFts"
|
|
$Stage = Join-Path $env:TEMP "wcy_publish_staging"
|
|
$Log = "D:\CodeBuddy\Pros\WenChuanyi\deploy\ftp_fast.log"
|
|
Set-Content -Path $Log -Value "start $(Get-Date -Format HH:mm:ss)" -Encoding UTF8
|
|
function L([string]$m){ Add-Content -Path $Log -Value $m -Encoding UTF8 }
|
|
function NewR($p,$m){ $r=[System.Net.FtpWebRequest]::Create("ftp://${FtpHost}/$p"); $r.Method=$m; $r.Credentials=New-Object System.Net.NetworkCredential($FtpUser,$FtpPass); $r.UsePassive=$true; $r.UseBinary=$true; $r.KeepAlive=$false; $r.Timeout=120000; $r }
|
|
function Mk($p){ $r=NewR $p ([System.Net.WebRequestMethods+Ftp]::MakeDirectory); try{$null=$r.GetResponse()}catch{} }
|
|
function Put($lp,$rp){
|
|
for($i=1;$i -le 3;$i++){
|
|
try{
|
|
$r=NewR $rp ([System.Net.WebRequestMethods+Ftp]::UploadFile)
|
|
$b=[IO.File]::ReadAllBytes($lp)
|
|
$r.ContentLength=$b.Length
|
|
$s=$r.GetRequestStream(); $s.Write($b,0,$b.Length); $s.Close()
|
|
$x=$r.GetResponse(); $x.Close()
|
|
L "OK $rp"; return
|
|
}catch{ L "RETRY($i) $rp : $($_.Exception.Message)"; Start-Sleep 3 }
|
|
}
|
|
L "FAIL $rp"
|
|
}
|
|
function Up($ld,$rd){
|
|
foreach($d in Get-ChildItem $ld -Directory){
|
|
# skip Kerberos native dir - rejected by server, not needed on Windows
|
|
if($d.FullName -match "win-x64[\\/]native$"){ L "SKIPDIR $($d.FullName)"; continue }
|
|
$c="$rd/$($d.Name)"; Mk $c; Up $d.FullName $c
|
|
}
|
|
foreach($f in Get-ChildItem $ld -File){ Put $f.FullName "$rd/$($f.Name)" }
|
|
}
|
|
Up $Stage "/wwwroot"
|
|
L "DONE $(Get-Date -Format HH:mm:ss)"
|