35 lines
1.4 KiB
PowerShell
35 lines
1.4 KiB
PowerShell
param(
|
|
[string]$PackageRoot = (Split-Path -Parent $PSScriptRoot),
|
|
[string]$InstallPath = "C:\Program Files\JR IT Services\HostAvailabilityMonitor",
|
|
[string]$ConfigRoot = "C:\ProgramData\JR IT Services\HostAvailabilityMonitor",
|
|
[switch]$RegisterEventSource,
|
|
[switch]$CreateBackup
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$repoScripts = Join-Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) 'scripts'
|
|
$monitorSource = Join-Path $PackageRoot 'monitor'
|
|
if (-not (Test-Path -LiteralPath $monitorSource)) {
|
|
$monitorSource = Join-Path (Split-Path -Parent $PackageRoot) 'monitor'
|
|
}
|
|
if (-not (Test-Path -LiteralPath $monitorSource)) {
|
|
throw "Monitor source folder not found below package root: $PackageRoot"
|
|
}
|
|
|
|
& (Join-Path $repoScripts 'install-on-server.ps1') `
|
|
-SourcePath $monitorSource `
|
|
-InstallPath $InstallPath `
|
|
-RegisterEventSource:$RegisterEventSource `
|
|
-CreateBackup:$CreateBackup
|
|
|
|
New-Item -Path $ConfigRoot -ItemType Directory -Force | Out-Null
|
|
$configFile = Join-Path $ConfigRoot 'appsettings.json'
|
|
$defaultConfig = Join-Path $InstallPath 'appsettings.json'
|
|
if ((Test-Path -LiteralPath $defaultConfig) -and (-not (Test-Path -LiteralPath $configFile))) {
|
|
Copy-Item -Path $defaultConfig -Destination $configFile -Force
|
|
}
|
|
Write-Host "[INFO] HostAvailabilityMonitor installed to $InstallPath"
|
|
Write-Host "[INFO] Config location: $configFile"
|