mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
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.
This commit is contained in:
parent
64b11108dc
commit
080aed5d7b
@ -38,6 +38,7 @@ namespace Remotely.Agent.Services
|
||||
private readonly IDeviceInformationService _deviceInfoService;
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
private readonly ILogger<AgentHubConnection> _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<ILoggerProvider> loggerProviders,
|
||||
ILogger<AgentHubConnection> logger)
|
||||
{
|
||||
_configService = configService;
|
||||
@ -68,6 +70,10 @@ namespace Remotely.Agent.Services
|
||||
_deviceInfoService = deviceInfoService;
|
||||
_httpFactory = httpFactory;
|
||||
_logger = logger;
|
||||
_fileLogger = loggerProviders
|
||||
.OfType<FileLoggerProvider>()
|
||||
.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;
|
||||
|
||||
@ -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<IActionResult> GetDesktop(string platformID)
|
||||
{
|
||||
@ -127,15 +126,13 @@ namespace Remotely.Server.API
|
||||
|
||||
private async Task<IActionResult> GetBashInstaller(string fileName, string organizationId)
|
||||
{
|
||||
var scheme = _appConfig.RedirectToHttps ? "https" : Request.Scheme;
|
||||
|
||||
var fileContents = new List<string>();
|
||||
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<IActionResult> 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);
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
"MaxConcurrentUpdates": 10,
|
||||
"MaxOrganizationCount": 1,
|
||||
"MessageOfTheDay": "",
|
||||
"RedirectToHttps": false,
|
||||
"RedirectToHttps": true,
|
||||
"RemoteControlNotifyUser": true,
|
||||
"RemoteControlRequiresAuthentication": true,
|
||||
"RemoteControlSessionLimit": 3,
|
||||
|
||||
@ -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="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
@ -84,7 +99,7 @@ plistFile="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/local/bin/dotnet</string>
|
||||
<string>/usr/local/bin/Remotely/Remotely_Agent.dll</string>
|
||||
<string>$InstallDir/Remotely_Agent.dll</string>
|
||||
</array>
|
||||
<key>KeepAlive</key>
|
||||
<true/>
|
||||
|
||||
@ -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="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
@ -90,7 +99,7 @@ plistFile="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/local/bin/dotnet</string>
|
||||
<string>/usr/local/bin/Remotely/Remotely_Agent.dll</string>
|
||||
<string>$InstallDir/Remotely_Agent.dll</string>
|
||||
</array>
|
||||
<key>KeepAlive</key>
|
||||
<true/>
|
||||
|
||||
@ -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
|
||||
echo Install complete. | tee -a $LogPath
|
||||
@ -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
|
||||
|
||||
@ -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<byte>();
|
||||
}
|
||||
finally
|
||||
|
||||
Loading…
Reference in New Issue
Block a user