-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from lucent-sea/mac-support
Mac support (agent only)
- Loading branch information
Showing
80 changed files
with
960 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,10 +33,51 @@ on: | |
|
||
jobs: | ||
|
||
build: | ||
build-mac: | ||
|
||
runs-on: macos-10.15 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install .NET Core | ||
uses: actions/[email protected] | ||
|
||
- name: Set current version | ||
shell: pwsh | ||
run: | | ||
$VersionString = git show -s --format=%ci | ||
$VersionDate = [DateTimeOffset]::Parse($VersionString) | ||
$Year = $VersionDate.Year.ToString() | ||
$Month = $VersionDate.Month.ToString().PadLeft(2, "0") | ||
$Day = $VersionDate.Day.ToString().PadLeft(2, "0") | ||
$Hour = $VersionDate.Hour.ToString().PadLeft(2, "0") | ||
$Minute = $VersionDate.Minute.ToString().PadLeft(2, "0") | ||
$CurrentVersion = "$Year.$Month.$Day.$Hour$Minute" | ||
echo "CurrentVersion=$CurrentVersion" >> $GITHUB_ENV | ||
Write-Host "Setting current version to $CurrentVersion." | ||
- name: Set current version | ||
shell: pwsh | ||
run: | | ||
dotnet publish /p:Version=$env:CurrentVersion /p:FileVersion=$env:CurrentVersion --runtime osx-x64 --configuration Release --output "./Agent/bin/publish" ".\Agent" | ||
Compress-Archive -Path "./Agent/bin/publish/*" -DestinationPath "./Agent/bin/Remotely-MacOS-x64.zip" -Force | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
path: ./Agent/bin/Remotely-MacOS-x64.zip | ||
name: Mac-Agent-x64 | ||
|
||
build-windows: | ||
|
||
runs-on: windows-latest # For a list of available runner types, refer to | ||
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | ||
needs: build-mac | ||
|
||
env: | ||
Solution_Name: Remotely.sln | ||
|
@@ -46,6 +87,13 @@ jobs: | |
ServerUrl: ${{ github.event.inputs.serverUrl }} | ||
|
||
steps: | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: Mac-Agent-x64 | ||
path: ./Server/wwwroot/Content/Remotely-MacOS-x64.zip | ||
|
||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,4 @@ | |
</ItemGroup> | ||
|
||
|
||
<ItemGroup> | ||
<Compile Update="Services\WindowsService.cs" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.SignalR.Client; | ||
using Remotely.Agent.Interfaces; | ||
|
||
namespace Remotely.Agent.Services | ||
{ | ||
public class AppLauncherMac : IAppLauncher | ||
{ | ||
public async Task<int> LaunchChatService(string orgName, string requesterID, HubConnection hubConnection) | ||
{ | ||
await hubConnection.SendAsync("DisplayMessage", "Feature under development.", "Feature is under development.", "bg-warning", requesterID); | ||
return 0; | ||
} | ||
|
||
public async Task LaunchRemoteControl(int targetSessionId, string requesterID, string serviceID, HubConnection hubConnection) | ||
{ | ||
await hubConnection.SendAsync("DisplayMessage", "Feature under development.", "Feature is under development.", "bg-warning", requesterID); | ||
} | ||
|
||
public async Task RestartScreenCaster(List<string> viewerIDs, string serviceID, string requesterID, HubConnection hubConnection, int targetSessionID = -1) | ||
{ | ||
await hubConnection.SendAsync("DisplayMessage", "Feature under development.", "Feature is under development.", "bg-warning", requesterID); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using Remotely.Agent.Interfaces; | ||
using Remotely.Shared.Models; | ||
using Remotely.Shared.Services; | ||
using Remotely.Shared.Utilities; | ||
using Remotely.Shared.Win32; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Remotely.Agent.Services | ||
{ | ||
public class DeviceInformationServiceMac : DeviceInformationServiceBase, IDeviceInformationService | ||
{ | ||
private readonly IProcessInvoker _processInvoker; | ||
|
||
public DeviceInformationServiceMac(IProcessInvoker processInvoker) | ||
{ | ||
_processInvoker = processInvoker; | ||
} | ||
public async Task<Device> CreateDevice(string deviceId, string orgId) | ||
{ | ||
var device = GetDeviceBase(deviceId, orgId); | ||
|
||
try | ||
{ | ||
|
||
var (usedStorage, totalStorage) = GetSystemDriveInfo(); | ||
var (usedMemory, totalMemory) = GetMemoryInGB(); | ||
|
||
device.CurrentUser = Environment.UserName; | ||
device.Drives = GetAllDrives(); | ||
device.UsedStorage = usedStorage; | ||
device.TotalStorage = totalStorage; | ||
device.UsedMemory = usedMemory; | ||
device.TotalMemory = totalMemory; | ||
device.CpuUtilization = await GetCpuUtilization(); | ||
device.AgentVersion = GetAgentVersion(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.Write(ex, "Error getting device info."); | ||
} | ||
|
||
return device; | ||
} | ||
|
||
public new Task<double> GetCpuUtilization() | ||
{ | ||
try | ||
{ | ||
var cpuPercentStrings = _processInvoker.InvokeProcessOutput("zsh", "-c \"ps -A -o %cpu\""); | ||
|
||
double cpuPercent = 0; | ||
cpuPercentStrings | ||
.Split(Environment.NewLine) | ||
.ToList() | ||
.ForEach(x => { | ||
if (double.TryParse(x, out var result)) | ||
{ | ||
cpuPercent += result; | ||
} | ||
}); | ||
|
||
return Task.FromResult(cpuPercent / Environment.ProcessorCount / 100); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.Write(ex, "Error while getting CPU utilization."); | ||
} | ||
|
||
return Task.FromResult((double)0); | ||
} | ||
|
||
public (double usedGB, double totalGB) GetMemoryInGB() | ||
{ | ||
try | ||
{ | ||
double totalGB = default; | ||
|
||
var totalMemoryString = _processInvoker.InvokeProcessOutput("zsh", "-c \"sysctl -n hw.memsize\""); | ||
if (double.TryParse(totalMemoryString, out var totalMemory)) | ||
{ | ||
totalGB = (double)Math.Round(totalMemory / 1024 / 1024 / 1024, 2); | ||
} | ||
|
||
|
||
double usedGB = default; | ||
|
||
var memPercentStrings = _processInvoker.InvokeProcessOutput("zsh", $"-c \"ps -A -o %mem\""); | ||
|
||
double usedMemPercent = 0; | ||
memPercentStrings | ||
.Split(Environment.NewLine) | ||
.ToList() | ||
.ForEach(x => { | ||
if (double.TryParse(x, out var result)) | ||
{ | ||
usedMemPercent += result; | ||
} | ||
}); | ||
|
||
usedMemPercent = usedMemPercent / 4 / 100; | ||
usedGB = usedMemPercent * totalGB; | ||
|
||
return (usedGB,totalGB); | ||
} | ||
catch | ||
{ | ||
return (0, 0); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.