mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Let installer use existing ConnectionInfo.
This commit is contained in:
parent
aff5af236c
commit
da2aac5e48
@ -38,7 +38,7 @@
|
||||
|
||||
<StackPanel>
|
||||
<TextBlock Style="{StaticResource SectionHeader}" Text="{Binding HeaderMessage}"></TextBlock>
|
||||
<Grid Margin="25,5,0,0" Visibility="{Binding IsServiceMissing, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<Grid Margin="25,5,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
|
||||
@ -203,6 +203,8 @@ namespace Remotely.Agent.Installer.Win.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
AddExistingConnectionInfo();
|
||||
|
||||
if (CommandLineParser.CommandLineArgs.ContainsKey("install"))
|
||||
{
|
||||
await Install(null);
|
||||
@ -235,6 +237,7 @@ namespace Remotely.Agent.Installer.Win.ViewModels
|
||||
var result = !string.IsNullOrWhiteSpace(OrganizationID) || !string.IsNullOrWhiteSpace(ServerUrl);
|
||||
if (!result)
|
||||
{
|
||||
Logger.Write("ServerUrl or OrganizationID param is missing. Unable to install.");
|
||||
MessageBoxEx.Show("Required settings are missing. Please enter a server URL and organization ID.", "Invalid Installer", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
return result;
|
||||
@ -272,6 +275,39 @@ namespace Remotely.Agent.Installer.Win.ViewModels
|
||||
ServerUrl = ServerUrl.Substring(0, ServerUrl.LastIndexOf("/"));
|
||||
}
|
||||
}
|
||||
|
||||
private void AddExistingConnectionInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var connectionInfoPath = Path.Combine(
|
||||
Path.GetPathRoot(Environment.SystemDirectory),
|
||||
"Program Files",
|
||||
"Remotely",
|
||||
"ConnectionInfo.json");
|
||||
|
||||
if (File.Exists(connectionInfoPath))
|
||||
{
|
||||
var serializer = new JavaScriptSerializer();
|
||||
var connectionInfo = serializer.Deserialize<ConnectionInfo>(File.ReadAllText(connectionInfoPath));
|
||||
|
||||
if (string.IsNullOrWhiteSpace(OrganizationID))
|
||||
{
|
||||
OrganizationID = connectionInfo.OrganizationID;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ServerUrl))
|
||||
{
|
||||
ServerUrl = connectionInfo.Host;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(ex);
|
||||
}
|
||||
|
||||
}
|
||||
private async Task Install(object param)
|
||||
{
|
||||
try
|
||||
|
||||
@ -54,7 +54,7 @@ namespace Remotely.Agent.Services
|
||||
proc.Kill();
|
||||
}
|
||||
|
||||
Process.Start(filePath, $"-install -quiet");
|
||||
Process.Start(filePath, $"-install -quiet -serverurl {connectionInfo.Host} -organizationid {connectionInfo.OrganizationID}");
|
||||
}
|
||||
else if (OSUtils.IsLinux)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user