Files
inquiry_robot/deploy/_remote_patch_inquiry_module.ps1
T

50 lines
1.9 KiB
PowerShell

# 远端:用新的 jeecg-module-inquiry jar 热补主账 fat jar,并重启 8180
$ErrorActionPreference = 'Stop'
$Incoming = 'C:\Users\ytd_extdev_0903\incoming'
$Root = 'E:\wwwroot\inquiry-new'
$Fat = Join-Path $Root 'jeecg-system-start-3.5.3.jar'
$NewMod = Join-Path $Incoming 'jeecg-module-inquiry-3.5.3.jar'
$Java = 'C:\yutongda\tools\jdk8\bin\jar.exe'
if (-not (Test-Path $Java)) { $Java = 'C:\yutongda\tools\jdk8\bin\jar' }
# prefer jar from PATH jdk
$jarCmd = $null
foreach ($c in @(
'C:\yutongda\tools\jdk8\bin\jar.exe',
'E:\wwwroot\tools\jdk-17\bin\jar.exe'
)) {
if (Test-Path $c) { $jarCmd = $c; break }
}
if (-not $jarCmd) { throw 'jar.exe not found' }
if (-not (Test-Path $NewMod)) { throw "missing $NewMod" }
if (-not (Test-Path $Fat)) { throw "missing $Fat" }
# stop ledger
Get-CimInstance Win32_Process -Filter "Name='java.exe'" | ForEach-Object {
if ($_.CommandLine -and $_.CommandLine -like '*inquiry-new*jeecg-system-start*') {
Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue
}
}
Start-Sleep -Seconds 2
$work = Join-Path $env:TEMP 'patch-inquiry-mod'
if (Test-Path $work) { Remove-Item $work -Recurse -Force }
New-Item -ItemType Directory $work | Out-Null
Copy-Item $Fat (Join-Path $work 'app.jar') -Force
Push-Location $work
New-Item -ItemType Directory -Force -Path 'BOOT-INF\lib' | Out-Null
Copy-Item $NewMod 'BOOT-INF\lib\jeecg-module-inquiry-3.5.3.jar' -Force
& $jarCmd uf app.jar 'BOOT-INF/lib/jeecg-module-inquiry-3.5.3.jar'
if ($LASTEXITCODE -ne 0) { Pop-Location; throw "jar uf failed $LASTEXITCODE" }
Copy-Item app.jar $Fat -Force
Pop-Location
Write-Host 'PATCH_JAR_OK'
# restart via existing WMI script if present
$start = Join-Path $Incoming '_remote_wmi_start_ledger.ps1'
if (Test-Path $start) {
& powershell -NoProfile -ExecutionPolicy Bypass -File $start
} else {
throw 'start script missing'
}
Write-Host 'PATCH_RESTART_DONE'