#1460 made the process name configurable

!wip
This commit is contained in:
Jamie.Rees 2017-10-18 14:24:27 +01:00
parent 7a8cc448c4
commit ec7e47c9cf
6 changed files with 34 additions and 29 deletions

View file

@ -172,7 +172,7 @@ namespace Ombi.Schedule.Jobs.Ombi
UseShellExecute = false,
CreateNoWindow = true,
FileName = $"Ombi.Updater{updaterExtension}",
Arguments = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + " " + extension,
Arguments = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + " " + (settings.ProcessName.HasValue() ? settings.ProcessName : "Ombi"),
WorkingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TempUpdate"),
};
if (settings.Username.HasValue())

View file

@ -5,5 +5,6 @@
public bool AutoUpdateEnabled { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string ProcessName { get; set; }
}
}

View file

@ -1,40 +1,37 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace Ombi.Updater
{
public class Installer
{
public void Start(StartupOptions options)
public void Start(StartupOptions opt)
{
// Kill Ombi Process
var p = new ProcessProvider();
p.Kill(options.OmbiProcessId);
p.Kill(opt.OmbiProcessId);
// Make sure the process has been killed
while (p.FindProcessByName("Ombi").Any())
while (p.FindProcessByName(opt.ProcessName).Any())
{
Thread.Sleep(500);
Console.WriteLine("Found another process called Ombi, KILLING!");
var proc = p.FindProcessByName("Ombi").FirstOrDefault();
var proc = p.FindProcessByName(opt.ProcessName).FirstOrDefault();
if (proc != null)
{
Console.WriteLine($"[{proc.Id}] - {proc.Name} - Path: {proc.StartPath}");
p.Kill(proc.Id);
}
Thread.Sleep(500);
}
MoveFiles(options);
MoveFiles(opt);
// Start Ombi
StartOmbi(options);
StartOmbi(opt);
}
private void StartOmbi(StartupOptions options)

View file

@ -21,25 +21,29 @@ namespace Ombi.Updater
private static StartupOptions CheckArgs(string[] args)
{
if(args.Length <= 0)
if(args.Length <= 1)
{
Console.WriteLine("No Args Provided... Exiting");
Environment.Exit(1);
}
var p = new ProcessProvider();
var ombiProc = p.FindProcessByName("Ombi").FirstOrDefault();
return new StartupOptions
var startup = new StartupOptions
{
ApplicationPath = args[0],
OmbiProcessId = ombiProc?.Id ?? -1
ProcessName = args[1],
};
var p = new ProcessProvider();
var ombiProc = p.FindProcessByName(startup.ProcessName).FirstOrDefault();
startup.OmbiProcessId = ombiProc?.Id ?? -1;
return startup;
}
}
public class StartupOptions
{
public string ProcessName { get; set; }
public string ApplicationPath { get; set; }
public int OmbiProcessId { get; set; }
}

View file

@ -19,6 +19,7 @@ export interface IUpdateSettings extends ISettings {
autoUpdateEnabled: boolean;
username: string;
password: string;
processName: string;
}
export interface IEmbySettings extends ISettings {

View file

@ -22,21 +22,23 @@
<small>If you are getting any permissions issues, you can specify a user for the update process to run under.</small>
<div class="form-group">
<input type="text" id="username" class="form-control form-control-custom" formControlName="username">
<label for="username">Username</label>
</div>
<div class="form-group">
<input type="password" id="password" class="form-control form-control-custom" formControlName="password">
<label for="username" class="control-label">Username</label>
<input type="text" class="form-control form-control-custom " id="username" name="username" formControlName="username">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" class="form-control form-control-custom" formControlName="password">
</div>
<small>By default the process name is Ombi, but this could be different for your system. We need to know the process name so we can kill that process to update the files.</small>
<div class="form-group">
<label for="processName">Ombi Process Name</label>
<input type="text" id="processName" class="form-control form-control-custom" placeholder="Ombi" formControlName="processName">
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-primary-outline ">Submit</button>