From b8b7884d92c646fbbaf051aeab0c7cab63a85751 Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 14 Feb 2018 14:00:03 +0000 Subject: [PATCH] Small changes to the auto updater, let's see how this works --- .../Jobs/Ombi/OmbiAutomaticUpdater.cs | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs b/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs index 38b669d76..42688376a 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/OmbiAutomaticUpdater.cs @@ -196,11 +196,14 @@ namespace Ombi.Schedule.Jobs.Ombi var updaterFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TempUpdate", $"Ombi.Updater{updaterExtension}"); + // Make sure the file is an executable + ExecLinuxCommand($"chmod +x {updaterFile}"); + // There must be an update var start = new ProcessStartInfo { - UseShellExecute = false, - CreateNoWindow = false, + UseShellExecute = true, + CreateNoWindow = false, // Ignored if UseShellExecute is set to true FileName = updaterFile, Arguments = GetArgs(settings), WorkingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TempUpdate"), @@ -367,5 +370,30 @@ namespace Ombi.Schedule.Jobs.Ombi Directory.Delete(path, true); } } + + public static void ExecLinuxCommand(string cmd) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return; + } + var escapedArgs = cmd.Replace("\"", "\\\""); + + var process = new Process + { + StartInfo = new ProcessStartInfo + { + RedirectStandardOutput = true, + UseShellExecute = false, + CreateNoWindow = true, + WindowStyle = ProcessWindowStyle.Hidden, + FileName = "/bin/bash", + Arguments = $"-c \"{escapedArgs}\"" + } + }; + + process.Start(); + process.WaitForExit(); + } } } \ No newline at end of file