Skip to content

Commit

Permalink
Connection verification now also checks connection via remote server'…
Browse files Browse the repository at this point in the history
…s IP if specified
  • Loading branch information
jiyuuma committed Apr 28, 2023
1 parent e753967 commit 12e7cf7
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions FastvueReporterInstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,16 @@ if ($IISVDir -ne "") {
}

if (!$FastvueReporterUrl) {
$FastvueReporterUrl = "http://localhost/$IISVDir"
if ($Server) {
# Localhost is still included when $Server is set as the script will be running on the server itself
$PossibleFastvueReporterUrls = @("http://localhost/$IISVDir", "http://127.0.0.1/$IISVDir", "http://${Server}/${IISVDir}");
$FastvueReporterUrl = "http://localhost/$IISVDir"
} else {
$PossibleFastvueReporterUrls = @("http://localhost/$IISVDir", "http://127.0.0.1/$IISVDir");
$FastvueReporterUrl = "http://localhost/$IISVDir"
}
} else {
$PossibleFastvueReporterUrls = @($FastvueReporterUrl);
}

# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -574,7 +583,7 @@ if (!$InstallerExecutablePath -and $PerformInstall) {
}
}

if ($Server) {
if ($Server -and !$InvokedFromRemote) {
# ------------------------------------------------------------------------------
# REMOTE MODE: Perform script operations on a remote system
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -606,7 +615,6 @@ if ($Server) {
}

$RemoteParameters = [hashtable]$PSBoundParameters
$RemoteParameters["Server"] = $null
$RemoteParameters["InvokedFromRemote"] = $true

Copy-Item -ToSession $RemoteSession $ThisScriptPath -Destination "$TempPath\FastvueReporterInstall.ps1" -ErrorAction Stop
Expand Down Expand Up @@ -738,13 +746,25 @@ if ($Server) {
$ErrorActionPreference = "SilentlyContinue"
$serviceResponsive = False
while (!$serviceResponsive) {
$response = Invoke-RestMethod -Credential $ApiCredential -TimeoutSec 2 -Uri "$FastvueReporterUrl/_/api?f=Service.Status"
$serviceResponsive = $?
foreach ($PossibleUrl in $PossibleFastvueReporterUrls) {
$response = Invoke-RestMethod -Credential $ApiCredential -TimeoutSec 2 -Uri "$PossibleUrl/_/api?f=Service.Status"
$serviceResponsive = $?

if ($serviceResponsive) {
$FastvueReporterUrl = $PossibleUrl
write-Host " - Connected via $FastvueReporterUrl"
} else {
if ((New-TimeSpan -Start $waitResponsiveStart).TotalSeconds -gt $waitResponsiveDuration) {
$ErrorActionPreference = $oldErrorActionPreference
Write-Error "Unable to verify connection to $ProductName at the following URLs after $waitResponsiveDuration seconds. Please check the installation configuration and try again."

if ((New-TimeSpan -Start $waitResponsiveStart).TotalSeconds -gt $waitResponsiveDuration) {
$ErrorActionPreference = $oldErrorActionPreference
Write-Error "Unable to verify connection to $ProductName at '$FastvueReporterUrl' after $waitResponsiveDuration seconds. Please check the installation configuration and try again."
Exit 1
foreach ($url in $PossibleFastvueReporterUrls) {
Write-Host " - $url"
}

Exit 1
}
}
}
}
$ErrorActionPreference = $oldErrorActionPreference
Expand Down

0 comments on commit 12e7cf7

Please sign in to comment.