Skip to content

Commit

Permalink
Merge pull request #844 from immense/update-downloads-page
Browse files Browse the repository at this point in the history
Update downloads page to reflect switch to PowerShell installer.
  • Loading branch information
dkattan authored Mar 11, 2024
2 parents 512d786 + 4172b40 commit 28ffab5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 47 deletions.
16 changes: 3 additions & 13 deletions Server/API/ClientDownloadsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ public async Task<IActionResult> GetInstaller(string platformID)
return await GetInstallFile(orgId, platformID);
}

[HttpGet("{organizationID}/{platformID}")]
public async Task<IActionResult> GetInstaller(string organizationID, string platformID)
[HttpGet("{platformId}/{organizationId}")]
public async Task<IActionResult> GetInstaller(string platformId, string organizationId)
{
return await GetInstallFile(organizationID, platformID);
return await GetInstallFile(organizationId, platformId);
}

private async Task<IActionResult> GetBashInstaller(string fileName, string organizationId)
Expand Down Expand Up @@ -172,16 +172,6 @@ private async Task<IActionResult> 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))
Expand Down
27 changes: 14 additions & 13 deletions Server/Components/Pages/Downloads.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

<div class="row mb-3">
<h4>Portable Instant Support Clients</h4>
<div class="text-info col-sm-12 ps-0 mb-2">
<p class="text-info col-sm-12 mb-2">
Instant desktop sharing. No account required.
</div>
</p>
<div class="col-sm-6 mb-3">
<strong>Windows (64-Bit)</strong>
<p>
Expand Down Expand Up @@ -47,9 +47,9 @@

<div class="row">
<h4>Resident Agents</h4>
<div class="text-info col-sm-12 ps-0 mb-2">
<p class="text-info col-sm-12 mb-2">
Installable background agents that provide unattended access and remote scripting.
</div>
</p>

@if (!_isAuthenticated)
{
Expand All @@ -63,7 +63,7 @@
<div class="col-sm-6 mb-3">
<strong>Windows 10 / 11 (64-Bit and 32-Bit)</strong>
<p>
<a target="_blank" href="/API/ClientDownloads/WindowsInstaller">Windows Installer (x64/x86)</a>
<a target="_blank" href="/API/ClientDownloads/WindowsInstaller/@_organizationId">Windows PowerShell Installer</a>
<br />
<a target="_blank" href="/Content/Remotely-Win-x64.zip">Windows x64 Files Only</a>
<br />
Expand All @@ -74,7 +74,7 @@
<div class="small">Example Quiet Install:</div>

<code class="label label-default small">
Remotely_Installer.exe
powershell.exe -ExecutionPolicy Bypass -F {path}\Install-Remotely.ps1
-install
-quiet
-organizationid "0b3d706b-9c5d-41e6-8ae9-5720d16324e6"
Expand All @@ -84,13 +84,13 @@
<p>
<div class="small">Example Quiet Uninstall:</div>

<code class="label label-default small">Remotely_Installer.exe -uninstall -quiet</code>
<code class="label label-default small">powershell.exe -ExecutionPolicy Bypass -F Install-Remotely.ps1 -uninstall -quiet</code>
</p>
<p>
<div class="small">Example Local Install:</div>

<code class="label label-default small">
Remotely_Installer.exe
powershell.exe -ExecutionPolicy Bypass -F {path}\Install-Remotely.ps1
-install
-quiet
-organizationid "0b3d706b-9c5d-41e6-8ae9-5720d16324e6"
Expand All @@ -102,7 +102,8 @@
<div class="small">All Override Options:</div>

<code class="label label-default small">
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"
Expand All @@ -115,9 +116,9 @@
<div class="col-sm-6 mb-3">
<strong>Linux 64-Bit</strong>
<p>
<a target="_blank" href="/API/ClientDownloads/UbuntuInstaller-x64">Ubuntu x64 Bash Installer</a>
<a target="_blank" href="/API/ClientDownloads/UbuntuInstaller-x64/@_organizationId">Ubuntu x64 Bash Installer</a>
<br />
<a target="_blank" href="/API/ClientDownloads/ManjaroInstaller-x64">Manjaro x64 Bash Installer</a>
<a target="_blank" href="/API/ClientDownloads/ManjaroInstaller-x64/@_organizationId">Manjaro x64 Bash Installer</a>
<br />
<a target="_blank" href="/Content/Remotely-Linux.zip">Linux x64 Files Only</a>
</p>
Expand All @@ -141,7 +142,7 @@
<div class="col-sm-6 mb-3">
<strong>macOS x64 (10.12 - 10.15)</strong>
<p>
<a target="_blank" href="/API/ClientDownloads/MacOSInstaller-x64">macOS x64 Bash Installer</a>
<a target="_blank" href="/API/ClientDownloads/MacOSInstaller-x64/@_organizationId">macOS x64 Bash Installer</a>
<br />
<a target="_blank" href="/Content/Remotely-MacOS-x64.zip">macOS x64 Files Only</a>
</p>
Expand All @@ -166,7 +167,7 @@
<div class="col-sm-6 mb-3">
<strong>macOS arm64</strong>
<p>
<a target="_blank" href="/API/ClientDownloads/MacOSInstaller-arm64">macOS arm64 Bash Installer</a>
<a target="_blank" href="/API/ClientDownloads/MacOSInstaller-arm64/@_organizationId">macOS arm64 Bash Installer</a>
<br />
<a target="_blank" href="/Content/Remotely-MacOS-arm64.zip">macOS arm64 Files Only</a>
</p>
Expand Down
48 changes: 27 additions & 21 deletions Server/wwwroot/Content/Install-Remotely.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,7 +33,7 @@ if ($OrganizationId) {

$ConnectionInfo = $null

if ([System.Environment]::Is64BitOperatingSystem){
if ([System.Environment]::Is64BitOperatingSystem) {
$Platform = "x64"
}
else {
Expand All @@ -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 {

Expand Down Expand Up @@ -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
}
Expand All @@ -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")) {
Expand All @@ -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 = "";
}
}
Expand All @@ -153,27 +159,27 @@ 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

New-Item -ItemType File -Path "$InstallPath\etag.txt" -Value $ETag -Force

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
}

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
}
Expand Down

0 comments on commit 28ffab5

Please sign in to comment.