From 080aed5d7b77fcad297be5d0be6b536de233778b Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Mon, 2 Jan 2023 14:03:09 -0800 Subject: [PATCH] Installer and client download fixes. (#549) * Check for empty ETag during install. Update log path. * Use effective theme in ClientDownloadsController. Fix typo. * Fix FileLogger pattern matching. * Change log wording. --- Agent/Services/AgentHubConnection.cs | 10 +++- Server/API/ClientDownloadsController.cs | 13 ++--- Server/Services/ApplicationConfig.cs | 2 +- Server/appsettings.json | 2 +- Server/wwwroot/Content/Install-MacOS-arm64.sh | 53 ++++++++++++------- Server/wwwroot/Content/Install-MacOS-x64.sh | 35 +++++++----- Server/wwwroot/Content/Install-Manjaro-x64.sh | 49 +++++++++-------- Server/wwwroot/Content/Install-Ubuntu-x64.sh | 49 +++++++++-------- Shared/Services/FileLogger.cs | 2 +- 9 files changed, 128 insertions(+), 87 deletions(-) diff --git a/Agent/Services/AgentHubConnection.cs b/Agent/Services/AgentHubConnection.cs index 59acded6..3626439a 100644 --- a/Agent/Services/AgentHubConnection.cs +++ b/Agent/Services/AgentHubConnection.cs @@ -38,6 +38,7 @@ namespace Remotely.Agent.Services private readonly IDeviceInformationService _deviceInfoService; private readonly IHttpClientFactory _httpFactory; private readonly ILogger _logger; + private readonly ILogger _fileLogger; private readonly ScriptExecutor _scriptExecutor; private readonly Uninstaller _uninstaller; @@ -57,6 +58,7 @@ namespace Remotely.Agent.Services IUpdater updater, IDeviceInformationService deviceInfoService, IHttpClientFactory httpFactory, + IEnumerable loggerProviders, ILogger logger) { _configService = configService; @@ -68,6 +70,10 @@ namespace Remotely.Agent.Services _deviceInfoService = deviceInfoService; _httpFactory = httpFactory; _logger = logger; + _fileLogger = loggerProviders + .OfType() + .FirstOrDefault() + ?.CreateLogger(nameof(AgentHubConnection)); } public bool IsConnected => _hubConnection?.State == HubConnectionState.Connected; @@ -242,7 +248,7 @@ namespace Remotely.Agent.Services _hubConnection.On("DeleteLogs", () => { - if (_logger is FileLogger logger) + if (_fileLogger is FileLogger logger) { logger.DeleteLogs(); } @@ -308,7 +314,7 @@ namespace Remotely.Agent.Services _hubConnection.On("GetLogs", async (string senderConnectionId) => { - if (_logger is not FileLogger logger) + if (_fileLogger is not FileLogger logger) { await _hubConnection.InvokeAsync("SendLogs", "Logger is not of expected type.", senderConnectionId).ConfigureAwait(false); return; diff --git a/Server/API/ClientDownloadsController.cs b/Server/API/ClientDownloadsController.cs index 8b344265..7ded4841 100644 --- a/Server/API/ClientDownloadsController.cs +++ b/Server/API/ClientDownloadsController.cs @@ -24,22 +24,21 @@ namespace Remotely.Server.API public class ClientDownloadsController : ControllerBase { private readonly IApplicationConfig _appConfig; - private readonly IDataService _dataService; private readonly IEmbeddedServerDataSearcher _embeddedDataSearcher; private readonly SemaphoreSlim _fileLock = new(1,1); private readonly IWebHostEnvironment _hostEnv; public ClientDownloadsController( IWebHostEnvironment hostEnv, - IDataService dataService, IApplicationConfig appConfig, IEmbeddedServerDataSearcher embeddedDataSearcher) { _hostEnv = hostEnv; _appConfig = appConfig; - _dataService = dataService; _embeddedDataSearcher = embeddedDataSearcher; } + private string EffectiveScheme => _appConfig.RedirectToHttps ? "https" : Request.Scheme; + [HttpGet("desktop/{platformID}")] public async Task GetDesktop(string platformID) { @@ -127,15 +126,13 @@ namespace Remotely.Server.API private async Task GetBashInstaller(string fileName, string organizationId) { - var scheme = _appConfig.RedirectToHttps ? "https" : Request.Scheme; - var fileContents = new List(); fileContents.AddRange(await System.IO.File.ReadAllLinesAsync(Path.Combine(_hostEnv.WebRootPath, "Content", fileName))); var hostIndex = fileContents.IndexOf("HostName="); var orgIndex = fileContents.IndexOf("Organization="); - fileContents[hostIndex] = $"HostName=\"{scheme}://{Request.Host}\""; + fileContents[hostIndex] = $"HostName=\"{EffectiveScheme}://{Request.Host}\""; fileContents[orgIndex] = $"Organization=\"{organizationId}\""; var fileBytes = Encoding.UTF8.GetBytes(string.Join("\n", fileContents)); return File(fileBytes, "application/octet-stream", fileName); @@ -143,7 +140,7 @@ namespace Remotely.Server.API private async Task GetDesktopFile(string filePath, string organizationId = null) { - var serverUrl = $"{Request.Scheme}://{Request.Host}"; + var serverUrl = $"{EffectiveScheme}://{Request.Host}"; var embeddedData = new EmbeddedServerData(new Uri(serverUrl), organizationId); var result = await _embeddedDataSearcher.GetRewrittenStream(filePath, embeddedData); @@ -166,7 +163,7 @@ namespace Remotely.Server.API case "WindowsInstaller": { var filePath = Path.Combine(_hostEnv.WebRootPath, "Content", "Remotely_Installer.exe"); - var serverUrl = $"{Request.Scheme}://{Request.Host}"; + var serverUrl = $"{EffectiveScheme}://{Request.Host}"; var embeddedData = new EmbeddedServerData(new Uri(serverUrl), organizationId); var result = await _embeddedDataSearcher.GetRewrittenStream(filePath, embeddedData); diff --git a/Server/Services/ApplicationConfig.cs b/Server/Services/ApplicationConfig.cs index 9d9951a6..d9aa5a5b 100644 --- a/Server/Services/ApplicationConfig.cs +++ b/Server/Services/ApplicationConfig.cs @@ -53,7 +53,7 @@ namespace Remotely.Server.Services public int MaxConcurrentUpdates => int.Parse(Config["ApplicationOptions:MaxConcurrentUpdates"] ?? "10"); public int MaxOrganizationCount => int.Parse(Config["ApplicationOptions:MaxOrganizationCount"] ?? "1"); public string MessageOfTheDay => Config["ApplicationOptions:MessageOfTheDay"]; - public bool RedirectToHttps => bool.Parse(Config["ApplicationOptions:RedirectToHttps"] ?? "false"); + public bool RedirectToHttps => bool.Parse(Config["ApplicationOptions:RedirectToHttps"] ?? "true"); public bool RemoteControlNotifyUser => bool.Parse(Config["ApplicationOptions:RemoteControlNotifyUser"] ?? "true"); public bool RemoteControlRequiresAuthentication => bool.Parse(Config["ApplicationOptions:RemoteControlRequiresAuthentication"] ?? "true"); public int RemoteControlSessionLimit => int.Parse(Config["ApplicationOptions:RemoteControlSessionLimit"] ?? "3"); diff --git a/Server/appsettings.json b/Server/appsettings.json index 717c40ed..3999604f 100644 --- a/Server/appsettings.json +++ b/Server/appsettings.json @@ -20,7 +20,7 @@ "MaxConcurrentUpdates": 10, "MaxOrganizationCount": 1, "MessageOfTheDay": "", - "RedirectToHttps": false, + "RedirectToHttps": true, "RemoteControlNotifyUser": true, "RemoteControlRequiresAuthentication": true, "RemoteControlSessionLimit": 3, diff --git a/Server/wwwroot/Content/Install-MacOS-arm64.sh b/Server/wwwroot/Content/Install-MacOS-arm64.sh index 759e2e70..6984c2ea 100644 --- a/Server/wwwroot/Content/Install-MacOS-arm64.sh +++ b/Server/wwwroot/Content/Install-MacOS-arm64.sh @@ -4,6 +4,11 @@ HostName= Organization= GUID="$(uuidgen)" UpdatePackagePath="" +InstallDir="/usr/local/bin/Remotely" +ETag=$(curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2) +LogPath="/var/log/remotely/Agent_Install.log" + +mkdir -p /var/log/remotely Args=( "$@" ) ArgLength=${#Args[@]} @@ -12,7 +17,7 @@ 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 -r -f $InstallDir/ rm -f /Library/LaunchDaemons/remotely-agent.plist exit elif [ "${Args[$i]}" = "--path" ]; then @@ -20,24 +25,35 @@ do fi done +if [ -z "$ETag" ]; then + echo "ETag is empty. Aborting install." | tee -a $LogPath + exit 1 +fi + # 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" + +if [[ -n "$SUDO_USER" && "$SUDO_USER" != "root" ]]; then + su - $SUDO_USER -c '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' +fi + +Owner=$(ls -l /usr/local/bin/brew | awk '{print $3}') + +su - $Owner -c "brew update" # Install .NET Runtime -su - $SUDO_USER -c "brew install --cask dotnet" +su - $Owner -c "brew install --cask dotnet" # Install dependency for System.Drawing.Common -su - $SUDO_USER -c "brew install mono-libgdiplus" +su - $Owner -c "brew install mono-libgdiplus" # Install other dependencies -su - $SUDO_USER -c "brew install curl" -su - $SUDO_USER -c "brew install jq" +su - $Owner -c "brew install curl" +su - $Owner -c "brew install jq" -if [ -f "/usr/local/bin/Remotely/ConnectionInfo.json" ]; then - SavedGUID=`cat "/usr/local/bin/Remotely/ConnectionInfo.json" | jq -r '.DeviceID'` +if [ -f "$InstallDir/ConnectionInfo.json" ]; then + SavedGUID=`su - $Owner -c "cat '$InstallDir/ConnectionInfo.json' | jq -r '.DeviceID'"` if [[ "$SavedGUID" != "null" && -n "$SavedGUID" ]]; then GUID="$SavedGUID" fi @@ -46,21 +62,20 @@ 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/ +mkdir -p $InstallDir +chmod -R 755 $InstallDir 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 + curl $HostName/Content/Remotely-MacOS-arm64.zip --output $InstallDir/Remotely-MacOS-arm64.zip else echo "Copying install files..." >> /tmp/Remotely_Install.log - cp "$UpdatePackagePath" /usr/local/bin/Remotely/Remotely-MacOS-arm64.zip + cp "$UpdatePackagePath" $InstallDir/Remotely-MacOS-arm64.zip rm -f "$UpdatePackagePath" fi -unzip -o ./Remotely-MacOS-arm64.zip -rm -f ./Remotely-MacOS-arm64.zip +unzip -o $InstallDir/Remotely-MacOS-arm64.zip +rm -f $InstallDir/Remotely-MacOS-arm64.zip connectionInfo="{ @@ -70,9 +85,9 @@ connectionInfo="{ \"ServerVerificationToken\":\"\" }" -echo "$connectionInfo" > ./ConnectionInfo.json +echo "$connectionInfo" > $InstallDir/ConnectionInfo.json -curl --head $HostName/Content/Remotely-MacOS-arm64.zip | grep -i "etag" | cut -d' ' -f 2 > ./etag.txt +curl --head $HostName/Content/Remotely-MacOS-arm64.zip | grep -i "etag" | cut -d' ' -f 2 > $InstallDir/etag.txt plistFile=" @@ -84,7 +99,7 @@ plistFile=" ProgramArguments /usr/local/bin/dotnet - /usr/local/bin/Remotely/Remotely_Agent.dll + $InstallDir/Remotely_Agent.dll KeepAlive diff --git a/Server/wwwroot/Content/Install-MacOS-x64.sh b/Server/wwwroot/Content/Install-MacOS-x64.sh index 15f84e24..7ea6ddf3 100644 --- a/Server/wwwroot/Content/Install-MacOS-x64.sh +++ b/Server/wwwroot/Content/Install-MacOS-x64.sh @@ -4,6 +4,11 @@ HostName= Organization= GUID="$(uuidgen)" UpdatePackagePath="" +InstallDir="/usr/local/bin/Remotely" +ETag=$(curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2) +LogPath="/var/log/remotely/Agent_Install.log" + +mkdir -p /var/log/remotely Args=( "$@" ) ArgLength=${#Args[@]} @@ -12,7 +17,7 @@ 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 -r -f $InstallDir/ rm -f /Library/LaunchDaemons/remotely-agent.plist exit elif [ "${Args[$i]}" = "--path" ]; then @@ -20,6 +25,11 @@ do fi done +if [ -z "$ETag" ]; then + echo "ETag is empty. Aborting install." | tee -a $LogPath + exit 1 +fi + # Install Homebrew @@ -42,8 +52,8 @@ su - $Owner -c "brew install curl" su - $Owner -c "brew install jq" -if [ -f "/usr/local/bin/Remotely/ConnectionInfo.json" ]; then - SavedGUID=`su - $Owner -c "cat '/usr/local/bin/Remotely/ConnectionInfo.json' | jq -r '.DeviceID'"` +if [ -f "$InstallDir/ConnectionInfo.json" ]; then + SavedGUID=`su - $Owner -c "cat '$InstallDir/ConnectionInfo.json' | jq -r '.DeviceID'"` if [[ "$SavedGUID" != "null" && -n "$SavedGUID" ]]; then GUID="$SavedGUID" fi @@ -52,21 +62,20 @@ 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/ +mkdir -p $InstallDir +chmod -R 755 $InstallDir if [ -z "$UpdatePackagePath" ]; then echo "Downloading client..." >> /tmp/Remotely_Install.log - curl $HostName/Content/Remotely-MacOS-x64.zip --output /usr/local/bin/Remotely/Remotely-MacOS-x64.zip + curl $HostName/Content/Remotely-MacOS-x64.zip --output $InstallDir/Remotely-MacOS-x64.zip else echo "Copying install files..." >> /tmp/Remotely_Install.log - cp "$UpdatePackagePath" /usr/local/bin/Remotely/Remotely-MacOS-x64.zip + cp "$UpdatePackagePath" $InstallDir/Remotely-MacOS-x64.zip rm -f "$UpdatePackagePath" fi -unzip -o ./Remotely-MacOS-x64.zip -rm -f ./Remotely-MacOS-x64.zip +unzip -o $InstallDir/Remotely-MacOS-x64.zip +rm -f $InstallDir/Remotely-MacOS-x64.zip connectionInfo="{ @@ -76,9 +85,9 @@ connectionInfo="{ \"ServerVerificationToken\":\"\" }" -echo "$connectionInfo" > ./ConnectionInfo.json +echo "$connectionInfo" > $InstallDir/ConnectionInfo.json -curl --head $HostName/Content/Remotely-MacOS-x64.zip | grep -i "etag" | cut -d' ' -f 2 > ./etag.txt +curl --head $HostName/Content/Remotely-MacOS-x64.zip | grep -i "etag" | cut -d' ' -f 2 > $InstallDir/etag.txt plistFile=" @@ -90,7 +99,7 @@ plistFile=" ProgramArguments /usr/local/bin/dotnet - /usr/local/bin/Remotely/Remotely_Agent.dll + $InstallDir/Remotely_Agent.dll KeepAlive diff --git a/Server/wwwroot/Content/Install-Manjaro-x64.sh b/Server/wwwroot/Content/Install-Manjaro-x64.sh index 68f28278..e9d8fe83 100644 --- a/Server/wwwroot/Content/Install-Manjaro-x64.sh +++ b/Server/wwwroot/Content/Install-Manjaro-x64.sh @@ -3,7 +3,11 @@ HostName= Organization= GUID=$(cat /proc/sys/kernel/random/uuid) UpdatePackagePath="" +InstallDir="/usr/local/bin/Remotely" +ETag=$(curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2) +LogPath="/var/log/remotely/Agent_Install.log" +mkdir -p /var/log/remotely Args=( "$@" ) ArgLength=${#Args[@]} @@ -12,7 +16,7 @@ for (( i=0; i<${ArgLength}; i+=2 )); do if [ "${Args[$i]}" = "--uninstall" ]; then systemctl stop remotely-agent - rm -r -f /usr/local/bin/Remotely + rm -r -f $InstallDir rm -f /etc/systemd/system/remotely-agent.service systemctl daemon-reload exit @@ -21,6 +25,11 @@ do fi done +if [ -z "$ETag" ]; then + echo "ETag is empty. Aborting install." | tee -a $LogPath + exit 1 +fi + pacman -Sy pacman -S dotnet-runtime-6.0 --noconfirm pacman -S libx11 --noconfirm @@ -32,33 +41,31 @@ pacman -S xclip --noconfirm pacman -S jq --noconfirm pacman -S curl --noconfirm -if [ -f "/usr/local/bin/Remotely/ConnectionInfo.json" ]; then - SavedGUID=`cat "/usr/local/bin/Remotely/ConnectionInfo.json" | jq -r '.DeviceID'` +if [ -f "$InstallDir/ConnectionInfo.json" ]; then + SavedGUID=`cat "$InstallDir/ConnectionInfo.json" | jq -r '.DeviceID'` if [[ "$SavedGUID" != "null" && -n "$SavedGUID" ]]; then GUID="$SavedGUID" fi fi -rm -r -f /usr/local/bin/Remotely +rm -r -f $InstallDir rm -f /etc/systemd/system/remotely-agent.service -mkdir -p /usr/local/bin/Remotely/ -cd /usr/local/bin/Remotely/ +mkdir -p $InstallDir if [ -z "$UpdatePackagePath" ]; then - echo "Downloading client..." >> /tmp/Remotely_Install.log - wget $HostName/Content/Remotely-Linux.zip + echo "Downloading client." | tee -a $LogPath + wget -q -O /tmp/Remotely-Linux.zip $HostName/Content/Remotely-Linux.zip else - echo "Copying install files..." >> /tmp/Remotely_Install.log - cp "$UpdatePackagePath" /usr/local/bin/Remotely/Remotely-Linux.zip + echo "Copying install files." | tee -a $LogPath + cp "$UpdatePackagePath" /tmp/Remotely-Linux.zip rm -f "$UpdatePackagePath" fi -unzip ./Remotely-Linux.zip -rm -f ./Remotely-Linux.zip -chmod +x ./Remotely_Agent -chmod +x ./Desktop/Remotely_Desktop - +unzip -o /tmp/Remotely-Linux.zip -d $InstallDir +rm -f /tmp/Remotely-Linux.zip +chmod +x $InstallDir/Remotely_Agent +chmod +x $InstallDir/Desktop/Remotely_Desktop connectionInfo="{ \"DeviceID\":\"$GUID\", @@ -67,18 +74,18 @@ connectionInfo="{ \"ServerVerificationToken\":\"\" }" -echo "$connectionInfo" > ./ConnectionInfo.json +echo "$connectionInfo" > $InstallDir/ConnectionInfo.json -curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2 > ./etag.txt +curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2 > $InstallDir/etag.txt -echo Creating service... >> /tmp/Remotely_Install.log +echo Creating service... | tee -a $LogPath serviceConfig="[Unit] Description=The Remotely agent used for remote access. [Service] -WorkingDirectory=/usr/local/bin/Remotely/ -ExecStart=/usr/local/bin/Remotely/Remotely_Agent +WorkingDirectory=$InstallDir +ExecStart=$InstallDir/Remotely_Agent Restart=always StartLimitIntervalSec=0 RestartSec=10 @@ -91,4 +98,4 @@ echo "$serviceConfig" > /etc/systemd/system/remotely-agent.service systemctl enable remotely-agent systemctl restart remotely-agent -echo Install complete. >> /tmp/Remotely_Install.log \ No newline at end of file +echo Install complete. | tee -a $LogPath \ No newline at end of file diff --git a/Server/wwwroot/Content/Install-Ubuntu-x64.sh b/Server/wwwroot/Content/Install-Ubuntu-x64.sh index d591ec1c..98903975 100644 --- a/Server/wwwroot/Content/Install-Ubuntu-x64.sh +++ b/Server/wwwroot/Content/Install-Ubuntu-x64.sh @@ -3,8 +3,11 @@ HostName= Organization= GUID=$(cat /proc/sys/kernel/random/uuid) UpdatePackagePath="" +InstallDir="/usr/local/bin/Remotely" +ETag=$(curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2) +LogPath="/var/log/remotely/Agent_Install.log" - +mkdir -p /var/log/remotely Args=( "$@" ) ArgLength=${#Args[@]} @@ -12,7 +15,7 @@ for (( i=0; i<${ArgLength}; i+=2 )); do if [ "${Args[$i]}" = "--uninstall" ]; then systemctl stop remotely-agent - rm -r -f /usr/local/bin/Remotely + rm -r -f $InstallDir rm -f /etc/systemd/system/remotely-agent.service systemctl daemon-reload exit @@ -21,6 +24,11 @@ do fi done +if [ -z "$ETag" ]; then + echo "ETag is empty. Aborting install." | tee -a $LogPath + exit 1 +fi + UbuntuVersion=$(lsb_release -r -s) wget -q https://packages.microsoft.com/config/ubuntu/$UbuntuVersion/packages-microsoft-prod.deb -O packages-microsoft-prod.deb @@ -42,32 +50,31 @@ apt-get -y install jq apt-get -y install curl -if [ -f "/usr/local/bin/Remotely/ConnectionInfo.json" ]; then - SavedGUID=`cat "/usr/local/bin/Remotely/ConnectionInfo.json" | jq -r '.DeviceID'` +if [ -f "$InstallDir/ConnectionInfo.json" ]; then + SavedGUID=`cat "$InstallDir/ConnectionInfo.json" | jq -r '.DeviceID'` if [[ "$SavedGUID" != "null" && -n "$SavedGUID" ]]; then GUID="$SavedGUID" fi fi -rm -r -f /usr/local/bin/Remotely +rm -r -f $InstallDir rm -f /etc/systemd/system/remotely-agent.service -mkdir -p /usr/local/bin/Remotely/ -cd /usr/local/bin/Remotely/ +mkdir -p $InstallDir if [ -z "$UpdatePackagePath" ]; then - echo "Downloading client..." >> /tmp/Remotely_Install.log - wget $HostName/Content/Remotely-Linux.zip + echo "Downloading client." | tee -a $LogPath + wget -q -O /tmp/Remotely-Linux.zip $HostName/Content/Remotely-Linux.zip else - echo "Copying install files..." >> /tmp/Remotely_Install.log - cp "$UpdatePackagePath" /usr/local/bin/Remotely/Remotely-Linux.zip + echo "Copying install files." | tee -a $LogPath + cp "$UpdatePackagePath" /tmp/Remotely-Linux.zip rm -f "$UpdatePackagePath" fi -unzip ./Remotely-Linux.zip -rm -f ./Remotely-Linux.zip -chmod +x ./Remotely_Agent -chmod +x ./Desktop/Remotely_Desktop +unzip -o /tmp/Remotely-Linux.zip -d $InstallDir +rm -f /tmp/Remotely-Linux.zip +chmod +x $InstallDir/Remotely_Agent +chmod +x $InstallDir/Desktop/Remotely_Desktop connectionInfo="{ @@ -77,18 +84,18 @@ connectionInfo="{ \"ServerVerificationToken\":\"\" }" -echo "$connectionInfo" > ./ConnectionInfo.json +echo "$connectionInfo" > $InstallDir/ConnectionInfo.json -curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2 > ./etag.txt +curl --head $HostName/Content/Remotely-Linux.zip | grep -i "etag" | cut -d' ' -f 2 > $InstallDir/etag.txt -echo Creating service... >> /tmp/Remotely_Install.log +echo Creating service. | tee -a $LogPath serviceConfig="[Unit] Description=The Remotely agent used for remote access. [Service] -WorkingDirectory=/usr/local/bin/Remotely/ -ExecStart=/usr/local/bin/Remotely/Remotely_Agent +WorkingDirectory=$InstallDir +ExecStart=$InstallDir/Remotely_Agent Restart=always StartLimitIntervalSec=0 RestartSec=10 @@ -101,4 +108,4 @@ echo "$serviceConfig" > /etc/systemd/system/remotely-agent.service systemctl enable remotely-agent systemctl restart remotely-agent -echo Install complete. >> /tmp/Remotely_Install.log +echo Install complete. | tee -a $LogPath diff --git a/Shared/Services/FileLogger.cs b/Shared/Services/FileLogger.cs index 35c40c37..ca0325de 100644 --- a/Shared/Services/FileLogger.cs +++ b/Shared/Services/FileLogger.cs @@ -122,7 +122,7 @@ namespace Remotely.Shared.Services } catch (Exception ex) { - this.LogError(ex, "Error while reading all bytes."); + this.LogError(ex, "Error while reading all bytes from logs."); return Array.Empty(); } finally