Skip to content

Commit

Permalink
Use static files for ClickOnce setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Feb 17, 2021
1 parent 9bc070c commit 23547e2
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 51 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ A remote control and remote scripting solution, built with .NET Core, SignalR Co
[![Build Status](https://dev.azure.com/translucency/Remotely/_apis/build/status/Remotely-ReleaseBuild?branchName=master)](https://dev.azure.com/translucency/Remotely/_build/latest?definitionId=17&branchName=master)
![GitHub Build](https://github.com/lucent-sea/Remotely/workflows/GitHub%20Build/badge.svg)


> NOTE: Development has been suspended.
>
> I will be taking a break from Remotely during 2021 to make more time for family, self-care, and other interests. The repo will be archived until I resume development, so that I don't get overwhelmed with issues and requests.
>
> Take care and stay safe.
>
> \- Jared
## Donations
If this project has benefited you in some way, or if you just want to show appreciation, please consider donating to a charity.

Expand All @@ -16,7 +25,6 @@ You can also sponsor the project to unlock additional features on your self-host
[![PayPal Link](https://img.shields.io/badge/PayPal-Donate-brightgreen)](https://www.paypal.me/translucency)



## Project Links
Demo App: https://app.remotely.one
Website: https://remotely.one
Expand Down Expand Up @@ -109,6 +117,10 @@ An organization admin has access to the Organization page and server log entries
* For Linux, you'll also need to restart the Remotely service in systemd after overwriting the files.
* The only things that can't be overwritten are the database DB file (if using SQLite) and the `appsettings.Production.json`. These files should never exist in the publish output.

## Branding
Within the Account section, there is a tab for branding, which will apply to the quick support clients and Windows installer.

However, the clients will need to have been built from source with the server URL hard-coded in the apps for them to be able to retrieve the branding info.

## Configuration
The following settings are available in appsettings.json, under the ApplicationOptions section.
Expand Down
22 changes: 0 additions & 22 deletions Server/API/ClientDownloadsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,6 @@ public async Task<IActionResult> GetDesktop(string platformID)
}
}

[HttpGet("clickonce-setup/{architecture}/{organizationId}")]
public IActionResult GetClickOnceSetup(string architecture, string organizationId)
{
string clickOnceDir;

switch (architecture?.ToLower())
{
case "x64":
clickOnceDir = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Win-x64", "ClickOnce");
break;
case "x86":
clickOnceDir = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Win-x86", "ClickOnce");
break;
default:
return BadRequest();
}

var setupFilePath = Path.Combine(clickOnceDir, "setup.exe");
return File(new FileStream(setupFilePath, FileMode.Open, FileAccess.Read, FileShare.Read), "application/octet-stream", "setup.exe");
}


[ServiceFilter(typeof(ApiAuthorizationFilter))]
[HttpGet("{platformID}")]
public async Task<IActionResult> GetInstaller(string platformID)
Expand Down
37 changes: 10 additions & 27 deletions Server/Pages/Agents.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@
ViewData["Title"] = "Client Downloads";
}

@if (User.Identity.IsAuthenticated)
{
<div class="small mb-3">
<span class="fas fa-question-circle pointer"></span>
You are signed in. Instant support links will be specific to your organization and, if applicable, will be branded.
You can share these links directly with customers for download.
</div>
}

<div class="row mb-3">
<h4>Portable Instant Support Clients</h4>
<div class="text-info col-sm-12 pl-0 mb-2">
Expand Down Expand Up @@ -45,22 +36,14 @@
</div>


<div class="row mb-3">
<h4>Installable Instant Support Clients</h4>
<div class="text-info col-sm-12 pl-0 mb-2">
Light-weight, self-updating quick support clients. Once logged in, you can copy the links for distribution.
</div>

@if (!User.Identity.IsAuthenticated)
{

<div class="col-sm-6 mb-3">
<h6>Must be logged in to download.</h6>
@if (Model.IsServerUrlEmbedded)
{
<div class="row mb-3">
<h4>Installable Instant Support Clients</h4>
<div class="text-info col-sm-12 pl-0 mb-2">
Light-weight, self-updating quick support clients. Once logged in, you can copy the links for distribution.
</div>

}
else
{
<div class="col-sm-6 mb-3">
<h6>Windows (64-Bit)</h6>
<p>
Expand All @@ -69,7 +52,7 @@
<p>
<strong>Download:</strong>
<br />
<a href="/api/ClientDownloads/clickonce-setup/x64/@Model.CurrentOrganization.ID">Windows Installer</a>
<a href="~/Downloads/Win-x64/ClickOnce/setup.exe">Windows Installer</a>
</p>
</div>
<div class="col-sm-6">
Expand All @@ -80,13 +63,13 @@
<p>
<strong>Download:</strong>
<br />
<a href="/api/ClientDownloads/clickonce-setup/x64/@Model.CurrentOrganization.ID">Windows Installer</a>
<a href="~/Downloads/Win-x86/ClickOnce/setup.exe">Windows Installer</a>
</p>
</div>
}

</div>
}

</div>

<div class="row">
<h4>Resident Agents</h4>
Expand Down
29 changes: 28 additions & 1 deletion Server/Pages/Agents.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Remotely.Server.Services;
using Remotely.Shared.Models;
using System.IO;
using System.Threading.Tasks;

namespace Remotely.Server.Pages
{
public class AgentsModel : PageModel
{
private readonly IDataService _dataService;
private readonly IWebHostEnvironment _hostEnvironment;
private readonly UserManager<RemotelyUser> _userManager;
public AgentsModel(UserManager<RemotelyUser> userManager, IDataService dataService)

public AgentsModel(
UserManager<RemotelyUser> userManager,
IDataService dataService,
IWebHostEnvironment hostEnvironment)
{
_userManager = userManager;
_dataService = dataService;
_hostEnvironment = hostEnvironment;
}

public Organization CurrentOrganization { get; private set; }
public bool IsServerUrlEmbedded { get; private set; }

public async Task OnGet()
{
Expand All @@ -26,6 +35,24 @@ public async Task OnGet()
var currentUser = await _userManager.GetUserAsync(User);
CurrentOrganization = _dataService.GetOrganizationById(currentUser.OrganizationID);
}

var appFilePath = Path.Combine(
_hostEnvironment.WebRootPath,
"Downloads",
"Win-x64",
"ClickOnce",
"Remotely_Desktop.application");

try
{
await ClickOnceMiddleware.AppFileLock.WaitAsync();
var appContent = await System.IO.File.ReadAllTextAsync(appFilePath);
IsServerUrlEmbedded = appContent.Contains($"{Request.Scheme}://{Request.Host}");
}
finally
{
ClickOnceMiddleware.AppFileLock.Release();
}
}
}
}

0 comments on commit 23547e2

Please sign in to comment.