mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Linux auto-update working.
This commit is contained in:
parent
571f176c67
commit
d649a37d97
@ -49,10 +49,6 @@ namespace Remotely_Agent.Services
|
||||
ConnectionInfo.ServerVerificationToken = Guid.NewGuid().ToString().Replace("-","");
|
||||
await HubConnection.InvokeAsync("SetServerVerificationToken", ConnectionInfo.ServerVerificationToken);
|
||||
Utilities.SaveConnectionInfo(ConnectionInfo);
|
||||
if (!Program.IsDebug)
|
||||
{
|
||||
Updater.CheckForCoreUpdates();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -54,8 +54,8 @@ namespace Remotely_Agent.Services
|
||||
}
|
||||
|
||||
var wc = new WebClient();
|
||||
var latestVersion = wc.DownloadString(Utilities.GetConnectionInfo().Host + $"/API/CoreVersion/{platform}");
|
||||
var thisVersion = FileVersionInfo.GetVersionInfo("Remotely_Agent.dll").FileVersion.ToString();
|
||||
var latestVersion = wc.DownloadString(Utilities.GetConnectionInfo().Host + $"/Downloads/CurrentAgentVersion.txt").Trim();
|
||||
var thisVersion = FileVersionInfo.GetVersionInfo("Remotely_Agent.dll").FileVersion.ToString().Trim();
|
||||
if (thisVersion != latestVersion)
|
||||
{
|
||||
Logger.Write($"Service Updater: Downloading update. Current Version: {thisVersion}. Latest Version: {latestVersion}.");
|
||||
@ -75,6 +75,7 @@ namespace Remotely_Agent.Services
|
||||
}
|
||||
else if (OSUtils.IsLinux)
|
||||
{
|
||||
Process.Start("sudo", $"rm -r {Path.Combine(Path.GetTempPath(), "Remotely_Update")}");
|
||||
Process.Start("sudo", "apt-get install unzip").WaitForExit();
|
||||
Process.Start("sudo", $"unzip -o {tempFile} -d {Path.Combine(Path.GetTempPath(), "Remotely_Update")}").WaitForExit();
|
||||
Process.Start("sudo", $"chmod -R 777 {Path.Combine(Path.GetTempPath(), "Remotely_Update")}").WaitForExit();
|
||||
@ -120,13 +121,13 @@ namespace Remotely_Agent.Services
|
||||
Process.Start("sudo", "systemctl stop remotely-agent");
|
||||
}
|
||||
|
||||
foreach (var proc in Process.GetProcesses().Where(x =>
|
||||
foreach (var proc in Process.GetProcesses().Where(x =>
|
||||
x.ProcessName.Contains("Remotely_Agent") &&
|
||||
x.Id != Process.GetCurrentProcess().Id))
|
||||
{
|
||||
proc.Kill();
|
||||
}
|
||||
|
||||
|
||||
Logger.Write("Service Updater: Gathering files.");
|
||||
string targetDir = "";
|
||||
|
||||
@ -139,15 +140,32 @@ namespace Remotely_Agent.Services
|
||||
targetDir = "/usr/local/bin/Remotely";
|
||||
}
|
||||
|
||||
var subdirList = Directory.GetDirectories(Path.Combine(Path.GetTempPath(), "Remotely_Update"));
|
||||
var fileList = Directory.GetFiles(Path.Combine(Path.GetTempPath(), "Remotely_Update"));
|
||||
Logger.Write("Service Updater: Copying new files.");
|
||||
|
||||
|
||||
var fileList = Directory.GetFiles(Path.Combine(Path.GetTempPath(), "Remotely_Update"));
|
||||
foreach (var file in fileList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var targetPath = Path.Combine(targetDir, Path.GetFileName(file));
|
||||
File.Copy(file, targetPath, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(ex);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var subdirList = Directory.GetDirectories(Path.Combine(Path.GetTempPath(), "Remotely_Update"));
|
||||
|
||||
foreach (var subdir in subdirList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var targetPath = Path.Combine(targetDir, Path.GetDirectoryName(subdir));
|
||||
var targetPath = Path.Combine(targetDir, Path.GetFileName(subdir.TrimEnd(Path.DirectorySeparatorChar)));
|
||||
if (Directory.Exists(targetPath))
|
||||
{
|
||||
Directory.Delete(targetPath, true);
|
||||
@ -157,25 +175,10 @@ namespace Remotely_Agent.Services
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(ex);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
foreach (var file in fileList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var targetPath = Path.Combine(targetDir, Path.GetFileName(file));
|
||||
if (File.Exists(targetPath))
|
||||
{
|
||||
File.Delete(targetPath);
|
||||
}
|
||||
File.Move(file, targetPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(ex);
|
||||
}
|
||||
}
|
||||
Logger.Write("Service Updater: Update completed.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -0,0 +1 @@
|
||||
2019.03.11.2236
|
||||
@ -4,7 +4,7 @@ GUID=$(cat /proc/sys/kernel/random/uuid)
|
||||
|
||||
systemctl stop remotely-client
|
||||
rm -r -f /usr/local/bin/Remotely
|
||||
rm -f /etc/systemd/system/remotely-client.service
|
||||
rm -f /etc/systemd/system/remotely-agent.service
|
||||
systemctl daemon-reload
|
||||
|
||||
if [ "$1" = "--uninstall" ]; then
|
||||
|
||||
@ -56,6 +56,8 @@ Set-Location -Path (Get-Item -Path $PSScriptRoot).Parent.FullName
|
||||
|
||||
|
||||
if ($ArgList.Contains("c")) {
|
||||
# Add Current Version file to Downloads folder for clients to check.
|
||||
Set-Content -Path ".\Remotely_Server\wwwroot\Downloads\CurrentAgentVersion.txt" -Value $CurrentVersion.Trim() -Force
|
||||
# Copy .NET Framework ScreenCaster to Agent resources for embedding.
|
||||
if ((Test-Path -Path ".\Remotely_Agent\Resources") -eq $false) {
|
||||
New-Item -Path ".\Remotely_Agent\Resources" -ItemType Directory
|
||||
|
||||
Loading…
Reference in New Issue
Block a user