From 208a1be9703dd557ec65dd1d579ebddcfe936b10 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Fri, 8 Mar 2024 08:36:05 -0800 Subject: [PATCH 1/2] Update downloads page to reflect switch to PowerShell installer. --- Server/API/ClientDownloadsController.cs | 16 ++----- Server/Components/Pages/Downloads.razor | 27 ++++++------ Server/wwwroot/Content/Install-Remotely.ps1 | 46 ++++++++++++--------- 3 files changed, 43 insertions(+), 46 deletions(-) diff --git a/Server/API/ClientDownloadsController.cs b/Server/API/ClientDownloadsController.cs index 65d1a2e35..8638492ef 100644 --- a/Server/API/ClientDownloadsController.cs +++ b/Server/API/ClientDownloadsController.cs @@ -114,10 +114,10 @@ public async Task GetInstaller(string platformID) return await GetInstallFile(orgId, platformID); } - [HttpGet("{organizationID}/{platformID}")] - public async Task GetInstaller(string organizationID, string platformID) + [HttpGet("{platformId}/{organizationId}")] + public async Task GetInstaller(string platformId, string organizationId) { - return await GetInstallFile(organizationID, platformID); + return await GetInstallFile(organizationId, platformId); } private async Task GetBashInstaller(string fileName, string organizationId) @@ -172,16 +172,6 @@ private async Task GetInstallFile(string organizationId, string p case "WindowsInstaller": { var effectiveScheme = settings.ForceClientHttps ? "https" : Request.Scheme; - //var serverUrl = $"{effectiveScheme}://{Request.Host}"; - //var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "Remotely_Installer.exe"); - //var embeddedData = new EmbeddedServerData(new Uri(serverUrl), organizationId); - //var result = await _embeddedDataSearcher.GetAppendedStream(filePath, embeddedData); - - //if (!result.IsSuccess) - //{ - // throw result.Exception ?? new Exception(result.Reason); - //} - var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "Install-Remotely.ps1"); if (!FileIO.Exists(filePath)) diff --git a/Server/Components/Pages/Downloads.razor b/Server/Components/Pages/Downloads.razor index 7b9678efb..93c8f74ca 100644 --- a/Server/Components/Pages/Downloads.razor +++ b/Server/Components/Pages/Downloads.razor @@ -11,9 +11,9 @@

Portable Instant Support Clients

-
+

Instant desktop sharing. No account required. -

+

Windows (64-Bit)

@@ -47,9 +47,9 @@

Resident Agents

-
+

Installable background agents that provide unattended access and remote scripting. -

+

@if (!_isAuthenticated) { @@ -63,7 +63,7 @@
Windows 10 / 11 (64-Bit and 32-Bit)

- Windows Installer (x64/x86) + Windows PowerShell Installer
Windows x64 Files Only
@@ -74,7 +74,7 @@

Example Quiet Install:
- Remotely_Installer.exe + powershell.exe -ExecutionPolicy Bypass -F {path}\Install-Remotely.ps1 -install -quiet -organizationid "0b3d706b-9c5d-41e6-8ae9-5720d16324e6" @@ -84,13 +84,13 @@

Example Quiet Uninstall:
- Remotely_Installer.exe -uninstall -quiet + powershell.exe -ExecutionPolicy Bypass -F Install-Remotely.ps1 -uninstall -quiet

Example Local Install:
- Remotely_Installer.exe + powershell.exe -ExecutionPolicy Bypass -F {path}\Install-Remotely.ps1 -install -quiet -organizationid "0b3d706b-9c5d-41e6-8ae9-5720d16324e6" @@ -102,7 +102,8 @@
All Override Options:
- Remotely_Installer.exe -install -quiet -supportshortcut + powershell.exe -ExecutionPolicy Bypass -F {path}\Install-Remotely.ps1 + -install -quiet -supportshortcut -organizationid "0b3d706b-9c5d-41e6-8ae9-5720d16324e6" -serverurl "https://remotely.mytechshop.com" -devicegroup "Customer Group 1" @@ -115,9 +116,9 @@
Linux 64-Bit

- Ubuntu x64 Bash Installer + Ubuntu x64 Bash Installer
- Manjaro x64 Bash Installer + Manjaro x64 Bash Installer
Linux x64 Files Only

@@ -141,7 +142,7 @@
macOS x64 (10.12 - 10.15)

- macOS x64 Bash Installer + macOS x64 Bash Installer
macOS x64 Files Only

@@ -166,7 +167,7 @@
macOS arm64

- macOS arm64 Bash Installer + macOS arm64 Bash Installer
macOS arm64 Files Only

diff --git a/Server/wwwroot/Content/Install-Remotely.ps1 b/Server/wwwroot/Content/Install-Remotely.ps1 index 150fe9c7a..3f01426e4 100644 --- a/Server/wwwroot/Content/Install-Remotely.ps1 +++ b/Server/wwwroot/Content/Install-Remotely.ps1 @@ -14,7 +14,8 @@ param ( [string]$Path, [string]$OrganizationId, [string]$ServerUrl, - [switch]$Uninstall + [switch]$Uninstall, + [switch]$Quiet ) [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 @@ -32,7 +33,7 @@ if ($OrganizationId) { $ConnectionInfo = $null -if ([System.Environment]::Is64BitOperatingSystem){ +if ([System.Environment]::Is64BitOperatingSystem) { $Platform = "x64" } else { @@ -41,20 +42,22 @@ else { $InstallPath = "$env:ProgramFiles\Remotely" -function Write-Log($Message){ - Write-Host $Message +function Write-Log($Message) { + if (!$Quiet) { + Write-Host $Message + } "$((Get-Date).ToString()) - $Message" | Out-File -FilePath $LogPath -Append } -function Do-Exit(){ - Write-Host "Exiting..." +function Do-Exit() { + Write-Log "Exiting..." Start-Sleep -Seconds 3 exit } function Is-Administrator() { - $Identity = [Security.Principal.WindowsIdentity]::GetCurrent() - $Principal = New-Object System.Security.Principal.WindowsPrincipal -ArgumentList $Identity - return $Principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -} + $Identity = [Security.Principal.WindowsIdentity]::GetCurrent() + $Principal = New-Object System.Security.Principal.WindowsPrincipal -ArgumentList $Identity + return $Principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +} function Run-StartupChecks { @@ -86,6 +89,9 @@ function Run-StartupChecks { if ($Uninstall) { $Params += " -Uninstall" } + if ($Quiet) { + $Params += " -Quiet" + } Start-Process -FilePath powershell.exe -ArgumentList $Params -Verb RunAs exit } @@ -107,7 +113,7 @@ function Install-Remotely { $HeadResponse = Invoke-WebRequest -Uri "$HostName/Content/Remotely-Win-$Platform.zip" -Method Head -UseBasicParsing $ETag = $HeadResponse.Headers["ETag"] if (!$Etag) { - Write-Host "Failed to get ETag from server. Aborting install." + Write-Log "Failed to get ETag from server. Aborting install." } if ((Test-Path -Path "$InstallPath") -and (Test-Path -Path "$InstallPath\ConnectionInfo.json")) { @@ -124,9 +130,9 @@ function Install-Remotely { if (!$ConnectionInfo) { $ConnectionInfo = @{ - DeviceID = (New-Guid).ToString(); - Host = $HostName; - OrganizationID = $Organization; + DeviceID = (New-Guid).ToString(); + Host = $HostName; + OrganizationID = $Organization; ServerVerificationToken = ""; } } @@ -153,9 +159,9 @@ function Install-Remotely { } Stop-Remotely - Get-ChildItem -Path $InstallPath | Where-Object {$_.Name -notlike "ConnectionInfo.json"} | Remove-Item -Recurse -Force + Get-ChildItem -Path $InstallPath | Where-Object { $_.Name -notlike "ConnectionInfo.json" } | Remove-Item -Recurse -Force - Expand-Archive -Path "$env:TEMP\Remotely-Win-$Platform.zip" -DestinationPath "$InstallPath" -Force + Expand-Archive -Path "$env:TEMP\Remotely-Win-$Platform.zip" -DestinationPath "$InstallPath" -Force New-Item -ItemType File -Path "$InstallPath\ConnectionInfo.json" -Value (ConvertTo-Json -InputObject $ConnectionInfo) -Force @@ -163,12 +169,12 @@ function Install-Remotely { if ($DeviceAlias -or $DeviceGroup) { $DeviceSetupOptions = @{ - DeviceAlias = $DeviceAlias; + DeviceAlias = $DeviceAlias; DeviceGroupName = $DeviceGroup; - OrganizationID = $Organization; - DeviceID = $ConnectionInfo.DeviceID; + OrganizationID = $Organization; + DeviceID = $ConnectionInfo.DeviceID; } - + $Body = $DeviceSetupOptions | ConvertTo-Json Invoke-RestMethod -Method Post -ContentType "application/json" -Uri "$HostName/api/devices" -Body $Body } From 4172b40e8eff31d91c64aea9b03a24b244f4a3d4 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Mon, 11 Mar 2024 04:59:16 -0700 Subject: [PATCH 2/2] Add quotes around service bin path. --- Server/wwwroot/Content/Install-Remotely.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/wwwroot/Content/Install-Remotely.ps1 b/Server/wwwroot/Content/Install-Remotely.ps1 index 3f01426e4..0c4f6ca5b 100644 --- a/Server/wwwroot/Content/Install-Remotely.ps1 +++ b/Server/wwwroot/Content/Install-Remotely.ps1 @@ -179,7 +179,7 @@ function Install-Remotely { Invoke-RestMethod -Method Post -ContentType "application/json" -Uri "$HostName/api/devices" -Body $Body } - New-Service -Name "Remotely_Service" -BinaryPathName "$InstallPath\Remotely_Agent.exe" -DisplayName "Remotely Service" -StartupType Automatic -Description "Background service that maintains a connection to the Remotely server. The service is used for remote support and maintenance by this computer's administrators." + New-Service -Name "Remotely_Service" -BinaryPathName "`"$InstallPath\Remotely_Agent.exe`"" -DisplayName "Remotely Service" -StartupType Automatic -Description "Background service that maintains a connection to the Remotely server. The service is used for remote support and maintenance by this computer's administrators." Start-Process -FilePath "cmd.exe" -ArgumentList "/c sc.exe failure `"Remotely_Service`" reset=5 actions=restart/5000" -Wait -WindowStyle Hidden Start-Service -Name Remotely_Service }