Updater: Add logic for .NET Core

This commit is contained in:
flightlevel
2019-03-03 15:44:18 +11:00
parent 4d4c9fe645
commit 53bd7ce0c4

View File

@@ -19,6 +19,7 @@ namespace Jackett.Updater
private IProcessService processService; private IProcessService processService;
private IServiceConfigService windowsService; private IServiceConfigService windowsService;
private Logger logger; private Logger logger;
Variants.JackettVariant variant = Variants.JackettVariant.NotFound;
public static void Main(string[] args) public static void Main(string[] args)
{ {
@@ -38,6 +39,10 @@ namespace Jackett.Updater
logger.Info("Jackett Updater v" + GetCurrentVersion()); logger.Info("Jackett Updater v" + GetCurrentVersion());
logger.Info("Options \"" + string.Join("\" \"", args) + "\""); logger.Info("Options \"" + string.Join("\" \"", args) + "\"");
Variants variants = new Variants();
variant = variants.GetVariant();
logger.Info("Jackett variant: " + variant.ToString());
bool isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT; bool isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT;
if (isWindows) if (isWindows)
{ {
@@ -351,7 +356,7 @@ namespace Jackett.Updater
var startInfo = new ProcessStartInfo() var startInfo = new ProcessStartInfo()
{ {
Arguments = options.Args, Arguments = options.Args,
FileName = Path.Combine(options.Path, "JackettConsole.exe"), FileName = GetJackettConsolePath(options.Path),
UseShellExecute = true UseShellExecute = true
}; };
@@ -363,7 +368,8 @@ namespace Jackett.Updater
startInfo.CreateNoWindow = false; startInfo.CreateNoWindow = false;
startInfo.WindowStyle = ProcessWindowStyle.Normal; startInfo.WindowStyle = ProcessWindowStyle.Normal;
} }
else
if (variant == Variants.JackettVariant.Mono)
{ {
startInfo.Arguments = startInfo.FileName + " " + startInfo.Arguments; startInfo.Arguments = startInfo.FileName + " " + startInfo.Arguments;
startInfo.FileName = "mono"; startInfo.FileName = "mono";
@@ -380,5 +386,18 @@ namespace Jackett.Updater
var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase); var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase);
return new FileInfo(WebUtility.UrlDecode(location.AbsolutePath)).DirectoryName; return new FileInfo(WebUtility.UrlDecode(location.AbsolutePath)).DirectoryName;
} }
private string GetJackettConsolePath(string directoryPath)
{
if (variant == Variants.JackettVariant.CoreMacOs || variant == Variants.JackettVariant.CoreLinuxAmd64 ||
variant == Variants.JackettVariant.CoreLinuxArm32 || variant == Variants.JackettVariant.CoreLinuxArm64)
{
return Path.Combine(directoryPath, "jackett");
}
else
{
return Path.Combine(directoryPath, "JackettConsole.exe");
}
}
} }
} }