From 66325ccc452b5e96d774549940e085b68bbf90dc Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Fri, 7 May 2021 10:47:10 -0700 Subject: [PATCH] Add macOS arm64. --- Agent/Services/UpdaterMac.cs | 7 +- Server/API/ClientDownloadsController.cs | 16 ++++ Server/Pages/Downloads.razor | 11 ++- Server/wwwroot/Content/Install-MacOS-arm64.sh | 93 +++++++++++++++++++ Server/wwwroot/Content/Install-MacOS-x64.sh | 2 +- 5 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 Server/wwwroot/Content/Install-MacOS-arm64.sh diff --git a/Agent/Services/UpdaterMac.cs b/Agent/Services/UpdaterMac.cs index 7f295d47..38e803c0 100644 --- a/Agent/Services/UpdaterMac.cs +++ b/Agent/Services/UpdaterMac.cs @@ -16,6 +16,7 @@ namespace Remotely.Agent.Services { public class UpdaterMac : IUpdater { + private readonly string _achitecture = RuntimeInformation.OSArchitecture.ToString().ToLower(); private readonly SemaphoreSlim _checkForUpdatesLock = new SemaphoreSlim(1, 1); private readonly ConfigService _configService; private readonly IWebClientEx _webClientEx; @@ -64,7 +65,7 @@ namespace Remotely.Agent.Services var connectionInfo = _configService.GetConnectionInfo(); var serverUrl = _configService.GetConnectionInfo().Host; - var fileUrl = serverUrl + $"/Content/Remotely-MacOS-x64.zip"; + var fileUrl = serverUrl + $"/Content/Remotely-MacOS-{_achitecture}.zip"; var lastEtag = string.Empty; @@ -128,11 +129,11 @@ namespace Remotely.Agent.Services var installerPath = Path.Combine(Path.GetTempPath(), "RemotelyUpdate.sh"); await _webClientEx.DownloadFileTaskAsync( - serverUrl + $"/API/ClientDownloads/{connectionInfo.OrganizationID}/MacOSInstaller-x64", + serverUrl + $"/API/ClientDownloads/{connectionInfo.OrganizationID}/MacOSInstaller-{_achitecture}", installerPath); await _webClientEx.DownloadFileTaskAsync( - serverUrl + $"/API/AgentUpdate/DownloadPackage/macos-x64/{downloadId}", + serverUrl + $"/API/AgentUpdate/DownloadPackage/macos-{_achitecture}/{downloadId}", zipPath); (await WebRequest.CreateHttp(serverUrl + $"/api/AgentUpdate/ClearDownload/{downloadId}").GetResponseAsync()).Dispose(); diff --git a/Server/API/ClientDownloadsController.cs b/Server/API/ClientDownloadsController.cs index adee4185..86e51f6f 100644 --- a/Server/API/ClientDownloadsController.cs +++ b/Server/API/ClientDownloadsController.cs @@ -55,6 +55,11 @@ namespace Remotely.Server.API var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "MacOS-x64", "Remotely_Desktop"); return await GetDesktopFile(filePath); } + case "MacOS-arm64": + { + var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "MacOS-arm64", "Remotely_Desktop"); + return await GetDesktopFile(filePath); + } default: return NotFound(); } @@ -86,6 +91,11 @@ namespace Remotely.Server.API var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "MacOS-x64", "Remotely_Desktop"); return await GetDesktopFile(filePath); } + case "MacOS-arm64": + { + var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "MacOS-arm64", "Remotely_Desktop"); + return await GetDesktopFile(filePath); + } default: return NotFound(); } @@ -186,6 +196,12 @@ namespace Remotely.Server.API { var fileName = "Install-MacOS-x64.sh"; + return await GetBashInstaller(fileName, organizationId); + } + case "MacOSInstaller-arm64": + { + var fileName = "Install-MacOS-arm64.sh"; + return await GetBashInstaller(fileName, organizationId); } default: diff --git a/Server/Pages/Downloads.razor b/Server/Pages/Downloads.razor index 61cc8208..b6f31d86 100644 --- a/Server/Pages/Downloads.razor +++ b/Server/Pages/Downloads.razor @@ -35,7 +35,8 @@
macOS (Catalina)

- macOS Executable + macOS x64 Executable + macOS arm64 Executable

@@ -175,9 +176,13 @@
macOS x64 (Catalina)

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

Example Install:
diff --git a/Server/wwwroot/Content/Install-MacOS-arm64.sh b/Server/wwwroot/Content/Install-MacOS-arm64.sh new file mode 100644 index 00000000..246acf71 --- /dev/null +++ b/Server/wwwroot/Content/Install-MacOS-arm64.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +HostName= +Organization= +GUID="$(uuidgen)" +UpdatePackagePath="" + +Args=( "$@" ) +ArgLength=${#Args[@]} + +for (( i=0; i<${ArgLength}; i+=2 )); +do + if [ "${Args[$i]}" = "--uninstall" ]; then + launchctl unload -w /Library/LaunchDaemons/remotely-agent.plist + rm -r -f /usr/local/bin/Remotely/ + rm -f /Library/LaunchDaemons/remotely-agent.plist + exit + elif [ "${Args[$i]}" = "--path" ]; then + UpdatePackagePath="${Args[$i+1]}" + fi +done + + +# Install Homebrew +su - $SUDO_USER -c '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' +su - $SUDO_USER -c "brew update" + +# Install .NET Runtime +su - $SUDO_USER -c "brew install --cask dotnet" + +# Install dependency for System.Drawing.Common +su - $SUDO_USER -c "brew install mono-libgdiplus" + +# Install other dependencies +su - $SUDO_USER -c "brew install curl" +su - $SUDO_USER -c "brew install jq" + + +if [ -f "/usr/local/bin/Remotely/ConnectionInfo.json" ]; then + GUID=`cat "/usr/local/bin/Remotely/ConnectionInfo.json" | jq -r '.DeviceID'` +fi + +rm -r -f /Applications/Remotely +rm -f /Library/LaunchDaemons/remotely-agent.plist + +mkdir -p /usr/local/bin/Remotely/ +chmod -R 755 /usr/local/bin/Remotely/ +cd /usr/local/bin/Remotely/ + +if [ -z "$UpdatePackagePath" ]; then + echo "Downloading client..." >> /tmp/Remotely_Install.log + curl $HostName/Content/Remotely-MacOS-arm64.zip --output /usr/local/bin/Remotely/Remotely-MacOS-arm64.zip +else + echo "Copying install files..." >> /tmp/Remotely_Install.log + cp "$UpdatePackagePath" /usr/local/bin/Remotely/Remotely-MacOS-arm64.zip + rm -f "$UpdatePackagePath" +fi + +unzip -o ./Remotely-MacOS-arm64.zip +rm -f ./Remotely-MacOS-arm64.zip + + +connectionInfo="{ + \"DeviceID\":\"$GUID\", + \"Host\":\"$HostName\", + \"OrganizationID\": \"$Organization\", + \"ServerVerificationToken\":\"\" +}" + +echo "$connectionInfo" > ./ConnectionInfo.json + +curl --head $HostName/Content/Remotely-MacOS-arm64.zip | grep -i "etag" | cut -d' ' -f 2 > ./etag.txt + + +plistFile=" + + + + Label + com.translucency.remotely-agent + ProgramArguments + + /usr/local/bin/dotnet + /usr/local/bin/Remotely/Remotely_Agent.dll + + KeepAlive + + +" +echo "$plistFile" > "/Library/LaunchDaemons/remotely-agent.plist" + +launchctl load -w /Library/LaunchDaemons/remotely-agent.plist +launchctl kickstart -k system/com.translucency.remotely-agent \ No newline at end of file diff --git a/Server/wwwroot/Content/Install-MacOS-x64.sh b/Server/wwwroot/Content/Install-MacOS-x64.sh index fbbb1894..06cbbb5c 100644 --- a/Server/wwwroot/Content/Install-MacOS-x64.sh +++ b/Server/wwwroot/Content/Install-MacOS-x64.sh @@ -1,4 +1,4 @@ -#!/bin/zsh +#!/bin/bash HostName= Organization=