Files
Printservice-REST/scripts/install-service.ps1
2026-06-09 22:13:00 +02:00

23 lines
1.1 KiB
PowerShell

param(
[string]$InstallDir = "C:\printservice-app",
[string]$ConfigDir = "C:\printservice",
[int]$Port = 8080,
[string]$Jar = "$PSScriptRoot\..\target\printservice-standalone.jar"
)
New-Item -ItemType Directory -Force -Path $InstallDir, "$InstallDir\logs", $ConfigDir | Out-Null
Copy-Item $Jar "$InstallDir\printservice-standalone.jar" -Force
Copy-Item "$PSScriptRoot\..\service\printservice.xml" "$InstallDir\printservice.xml" -Force
(Get-Content "$InstallDir\printservice.xml") `
-replace 'C:\\printservice', ($ConfigDir -replace '\\','\\') `
-replace '--port=8080', "--port=$Port" | Set-Content "$InstallDir\printservice.xml" -Encoding UTF8
Write-Host "Bitte WinSW-x64.exe als $InstallDir\printservice.exe ablegen, falls noch nicht vorhanden."
if (Test-Path "$InstallDir\printservice.exe") {
Push-Location $InstallDir
.\printservice.exe install
.\printservice.exe start
Pop-Location
} else {
Write-Host "Download WinSW, benenne es in printservice.exe um und fuehre danach aus:"
Write-Host "cd $InstallDir; .\printservice.exe install; .\printservice.exe start"
}