diff --git a/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs b/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs index 699116e3a..b85c6d0ad 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs @@ -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()) diff --git a/src/Ombi.Settings/Settings/Models/UpdateSettings.cs b/src/Ombi.Settings/Settings/Models/UpdateSettings.cs index e1a696161..3021aa4f0 100644 --- a/src/Ombi.Settings/Settings/Models/UpdateSettings.cs +++ b/src/Ombi.Settings/Settings/Models/UpdateSettings.cs @@ -5,5 +5,6 @@ public bool AutoUpdateEnabled { get; set; } public string Username { get; set; } public string Password { get; set; } + public string ProcessName { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Updater/Installer.cs b/src/Ombi.Updater/Installer.cs index 467a296fa..91f52858b 100644 --- a/src/Ombi.Updater/Installer.cs +++ b/src/Ombi.Updater/Installer.cs @@ -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) diff --git a/src/Ombi.Updater/Program.cs b/src/Ombi.Updater/Program.cs index 8e787d989..55e6797f4 100644 --- a/src/Ombi.Updater/Program.cs +++ b/src/Ombi.Updater/Program.cs @@ -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; } } diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index 55614ffe2..3710eb229 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -19,6 +19,7 @@ export interface IUpdateSettings extends ISettings { autoUpdateEnabled: boolean; username: string; password: string; + processName: string; } export interface IEmbySettings extends ISettings { diff --git a/src/Ombi/ClientApp/app/settings/update/update.component.html b/src/Ombi/ClientApp/app/settings/update/update.component.html index 207139197..0bdd9213b 100644 --- a/src/Ombi/ClientApp/app/settings/update/update.component.html +++ b/src/Ombi/ClientApp/app/settings/update/update.component.html @@ -22,21 +22,23 @@ If you are getting any permissions issues, you can specify a user for the update process to run under. + +