mirror of https://github.com/Jackett/Jackett
Merge branch 'master' of https://github.com/Jackett/Jackett
This commit is contained in:
commit
b95fbd76a7
|
@ -17,7 +17,7 @@ Developer note: The software implements the [Torznab](https://github.com/Sonarr/
|
|||
|
||||
#### Supported Systems
|
||||
* Windows using .NET 4.6.1 or above [Download here](https://www.microsoft.com/net/framework/versions/net461).
|
||||
* Linux and macOS using Mono 5.8 or above. [Download here](http://www.mono-project.com/download/). Earlier versions of mono may work, but some trackers may fail to negotiate SSL correctly, and others may cause Jackett to crash when used.
|
||||
* Linux and macOS using Mono 5.8 or above. [Download here](http://www.mono-project.com/download/).
|
||||
|
||||
### Supported Public Trackers
|
||||
* 1337x
|
||||
|
|
|
@ -270,15 +270,27 @@ namespace Jackett.Common.Services
|
|||
|
||||
private void StartUpdate(string updaterExePath, string installLocation, bool isWindows, bool NoRestart, bool trayWasRunning)
|
||||
{
|
||||
string appType = "Console";
|
||||
//DI once off Owin
|
||||
IProcessService processService = new ProcessService(logger);
|
||||
IServiceConfigService windowsService = new WindowsServiceConfigService(processService, logger);
|
||||
|
||||
if (isWindows && windowsService.ServiceExists())
|
||||
{
|
||||
appType = "WindowsService";
|
||||
}
|
||||
|
||||
var exe = Path.GetFileName(ExePath());
|
||||
var args = string.Join(" ", Environment.GetCommandLineArgs().Skip(1).Select(a => a.Contains(" ") ? "\"" +a + "\"" : a )).Replace("\"", "\\\"");
|
||||
|
||||
var startInfo = new ProcessStartInfo();
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.CreateNoWindow = true;
|
||||
|
||||
// Note: add a leading space to the --Args argument to avoid parsing as arguments
|
||||
if (isWindows)
|
||||
{
|
||||
startInfo.Arguments = $"--Path \"{installLocation}\" --Type \"{exe}\" --Args \" {args}\"";
|
||||
startInfo.Arguments = $"--Path \"{installLocation}\" --Type \"{appType}\" --Args \" {args}\"";
|
||||
startInfo.FileName = Path.Combine(updaterExePath);
|
||||
}
|
||||
else
|
||||
|
@ -287,13 +299,12 @@ namespace Jackett.Common.Services
|
|||
args = exe + " " + args;
|
||||
exe = "mono";
|
||||
|
||||
startInfo.Arguments = $"{Path.Combine(updaterExePath)} --Path \"{installLocation}\" --Type \"{exe}\" --Args \" {args}\"";
|
||||
startInfo.Arguments = $"{Path.Combine(updaterExePath)} --Path \"{installLocation}\" --Type \"{appType}\" --Args \" {args}\"";
|
||||
startInfo.FileName = "mono";
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.CreateNoWindow = true;
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
var pid = Process.GetCurrentProcess().Id;
|
||||
startInfo.Arguments += $" --KillPids \"{pid}\"";
|
||||
}
|
||||
|
@ -317,7 +328,7 @@ namespace Jackett.Common.Services
|
|||
var procInfo = Process.Start(startInfo);
|
||||
logger.Info($"Updater started process id: {procInfo.Id}");
|
||||
if (NoRestart == false)
|
||||
{
|
||||
{
|
||||
logger.Info("Exiting Jackett..");
|
||||
lockService.Signal();
|
||||
//TODO: Remove once off Owin
|
||||
|
|
|
@ -77,10 +77,12 @@ namespace Jackett.Service
|
|||
|
||||
private void ProcessExited(object sender, EventArgs e)
|
||||
{
|
||||
logger.Info("Console process exited");
|
||||
|
||||
if (!serviceStopInitiated)
|
||||
{
|
||||
logger.Info("Service stop not responsible for process exit");
|
||||
OnStop();
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +91,7 @@ namespace Jackett.Service
|
|||
if (consoleProcess != null && !consoleProcess.HasExited)
|
||||
{
|
||||
consoleProcess.StandardInput.Close();
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
consoleProcess.WaitForExit(2000);
|
||||
if (consoleProcess != null && !consoleProcess.HasExited)
|
||||
{
|
||||
consoleProcess.Kill();
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TrayConsoleOptions.cs" />
|
||||
<EmbeddedResource Include="Main.resx">
|
||||
<DependentUpon>Main.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
@ -109,6 +110,11 @@
|
|||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser">
|
||||
<Version>2.2.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Jackett.Tray
|
|||
private Logger logger;
|
||||
private bool closeApplicationInitiated;
|
||||
|
||||
public Main()
|
||||
public Main(string updatedVersion)
|
||||
{
|
||||
Hide();
|
||||
InitializeComponent();
|
||||
|
@ -65,12 +65,22 @@ namespace Jackett.Tray
|
|||
StartConsoleApplication();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(updatedVersion))
|
||||
{
|
||||
notifyIcon1.BalloonTipTitle = "Jackett";
|
||||
notifyIcon1.BalloonTipText = $"Jackett has updated to version {updatedVersion}";
|
||||
notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
|
||||
notifyIcon1.ShowBalloonTip(10000);
|
||||
logger.Info($"Display balloon tip, updated to {updatedVersion}");
|
||||
}
|
||||
|
||||
Task.Factory.StartNew(WaitForEvent);
|
||||
}
|
||||
|
||||
private void WaitForEvent()
|
||||
{
|
||||
trayLockService.WaitForSignal();
|
||||
logger.Info("Received signal from tray lock service");
|
||||
CloseTrayApplication();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using CommandLine;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
@ -11,7 +12,7 @@ namespace Jackett.Tray
|
|||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var JacketTrayProcess = Process.GetCurrentProcess();
|
||||
var runningProcesses = Process.GetProcesses();
|
||||
|
@ -23,10 +24,29 @@ namespace Jackett.Tray
|
|||
MessageBox.Show("JackettTray is already running");
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
string newVersion = "";
|
||||
var commandLineParser = new Parser(settings => settings.CaseSensitive = false);
|
||||
|
||||
try
|
||||
{
|
||||
var optionsResult = commandLineParser.ParseArguments<TrayConsoleOptions>(args);
|
||||
optionsResult.WithParsed(options =>
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(options.UpdatedVersion))
|
||||
{
|
||||
newVersion = options.UpdatedVersion;
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
newVersion = "";
|
||||
}
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Main());
|
||||
Application.Run(new Main(newVersion));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
using CommandLine;
|
||||
|
||||
namespace Jackett.Tray
|
||||
{
|
||||
public class TrayConsoleOptions
|
||||
{
|
||||
[Option("UpdatedVersion", HelpText = "Indicates the new version that Jackett just updated to so that user understands why they are getting a prompt to start Windows service")]
|
||||
public string UpdatedVersion { get; set; }
|
||||
}
|
||||
}
|
|
@ -38,6 +38,14 @@ namespace Jackett.Updater
|
|||
logger.Info("Jackett Updater v" + GetCurrentVersion());
|
||||
logger.Info("Options \"" + string.Join("\" \"", args) + "\"");
|
||||
|
||||
bool isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT;
|
||||
if (isWindows)
|
||||
{
|
||||
//The updater starts before Jackett closes
|
||||
logger.Info("Pausing for 3 seconds to give Jackett & tray time to shutdown");
|
||||
System.Threading.Tasks.Task.Delay(3000);
|
||||
}
|
||||
|
||||
processService = new ProcessService(logger);
|
||||
windowsService = new WindowsServiceConfigService(processService, logger);
|
||||
|
||||
|
@ -248,15 +256,16 @@ namespace Jackett.Updater
|
|||
|
||||
if (options.NoRestart == false)
|
||||
{
|
||||
if (trayRunning || options.StartTray)
|
||||
if (isWindows && (trayRunning || options.StartTray))
|
||||
{
|
||||
var startInfo = new ProcessStartInfo()
|
||||
{
|
||||
Arguments = options.Args,
|
||||
Arguments = $"--UpdatedVersion \" {EnvironmentUtil.JackettVersion}\"",
|
||||
FileName = Path.Combine(options.Path, "JackettTray.exe"),
|
||||
UseShellExecute = true
|
||||
};
|
||||
|
||||
logger.Info("Starting Tray: " + startInfo.FileName + " " + startInfo.Arguments);
|
||||
Process.Start(startInfo);
|
||||
|
||||
if (!windowsService.ServiceExists())
|
||||
|
@ -266,12 +275,27 @@ namespace Jackett.Updater
|
|||
}
|
||||
}
|
||||
|
||||
if (string.Equals(options.Type, "JackettService.exe", StringComparison.InvariantCultureIgnoreCase))
|
||||
if (string.Equals(options.Type, "WindowsService", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
if (windowsService.ServiceExists())
|
||||
logger.Info("Starting Windows service");
|
||||
|
||||
if (ServerUtil.IsUserAdministrator())
|
||||
{
|
||||
windowsService.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
var consolePath = Path.Combine(options.Path, "JackettConsole.exe");
|
||||
processService.StartProcessAndLog(consolePath, "--Start", true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
logger.Error("Failed to get admin rights to start the service.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue