mirror of https://github.com/Jackett/Jackett
Various bugfixes.
This commit is contained in:
parent
960720b3e4
commit
f31f89037c
|
@ -51,6 +51,7 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang
|
|||
[Run]
|
||||
Filename: "{app}\JackettConsole.exe"; Parameters: "--Uninstall"; Flags: waituntilterminated;
|
||||
Filename: "{app}\JackettConsole.exe"; Parameters: "--ReserveUrls"; Flags: waituntilterminated;
|
||||
Filename: "{app}\JackettConsole.exe"; Parameters: "--MigrateSettings"; Flags: waituntilterminated;
|
||||
Filename: "{app}\JackettConsole.exe"; Parameters: "--Install"; Flags: waituntilterminated; Tasks: windowsService
|
||||
Filename: "{app}\JackettConsole.exe"; Parameters: "--Start"; Flags: waituntilterminated; Tasks: windowsService
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ namespace Jackett.Console
|
|||
[Option('u', "Uninstall", HelpText = "Uninstall Jackett windows service (Must be admin).")]
|
||||
public bool Uninstall { get; set; }
|
||||
|
||||
[Option('l', "Logging", DefaultValue = false, HelpText = "Log all requests/responses to Jackett")]
|
||||
[Option('l', "Logging", HelpText = "Log all requests/responses to Jackett")]
|
||||
public bool Logging { get; set; }
|
||||
|
||||
[Option('t', "Tracing", DefaultValue = false, HelpText = "Enable tracing")]
|
||||
[Option('t', "Tracing", HelpText = "Enable tracing")]
|
||||
public bool Tracing { get; set; }
|
||||
|
||||
[Option('c', "UseCurlExec", DefaultValue = false, HelpText = "Execute curl rather than libcurl for all outgoing requests.")]
|
||||
[Option('c', "UseCurlExec", HelpText = "Execute curl rather than libcurl for all outgoing requests.")]
|
||||
public bool UseCurlExec { get; set; }
|
||||
|
||||
[Option('s', "Start", HelpText = "Start the Jacket Windows service (Must be admin)")]
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
|
|
|
@ -34,6 +34,31 @@ namespace JackettConsole
|
|||
}
|
||||
else
|
||||
{
|
||||
/* ====== Options ===== */
|
||||
|
||||
// Use curl
|
||||
if (options.UseCurlExec)
|
||||
Startup.CurlSafe = true;
|
||||
|
||||
// Logging
|
||||
if (options.Logging)
|
||||
Startup.LogRequests = true;
|
||||
|
||||
// Tracing
|
||||
if (options.Tracing)
|
||||
Startup.TracingEnabled = true;
|
||||
|
||||
// Log after the fact as using the logger will cause the options above to be used
|
||||
|
||||
if (options.UseCurlExec)
|
||||
Engine.Logger.Info("Safe curl enabled.");
|
||||
|
||||
if (options.Logging)
|
||||
Engine.Logger.Info("Logging enabled.");
|
||||
|
||||
if (options.Tracing)
|
||||
Engine.Logger.Info("Tracing enabled.");
|
||||
|
||||
/* ====== Actions ===== */
|
||||
|
||||
// Install service
|
||||
|
@ -54,7 +79,6 @@ namespace JackettConsole
|
|||
// Reserve urls
|
||||
if (options.ReserveUrls)
|
||||
{
|
||||
Engine.ConfigService.CreateOrMigrateSettings();
|
||||
Engine.Server.ReserveUrls(doInstall: true);
|
||||
return;
|
||||
}
|
||||
|
@ -81,11 +105,8 @@ namespace JackettConsole
|
|||
|
||||
// Migrate settings
|
||||
if (options.MigrateSettings)
|
||||
{
|
||||
if (Engine.ServiceConfig.ServiceRunning())
|
||||
{
|
||||
Engine.ConfigService.PerformMigration();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -97,31 +118,14 @@ namespace JackettConsole
|
|||
return;
|
||||
}
|
||||
|
||||
/* ====== Options ===== */
|
||||
|
||||
// Logging
|
||||
if (options.Logging)
|
||||
{
|
||||
Startup.LogRequests = true;
|
||||
}
|
||||
|
||||
// Tracing
|
||||
if (options.Tracing)
|
||||
{
|
||||
Startup.TracingEnabled = true;
|
||||
}
|
||||
|
||||
// Use curl
|
||||
if (options.UseCurlExec)
|
||||
{
|
||||
Startup.CurlSafe = true;
|
||||
}
|
||||
/* ====== Overrides ===== */
|
||||
|
||||
// Override listen public
|
||||
if(options.ListenPublic.HasValue)
|
||||
{
|
||||
if (Engine.Server.Config.AllowExternal != options.ListenPublic)
|
||||
{
|
||||
Engine.Logger.Info("Overriding external access to " + options.ListenPublic);
|
||||
Engine.Server.Config.AllowExternal = options.ListenPublic.Value;
|
||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
{
|
||||
|
@ -146,6 +150,7 @@ namespace JackettConsole
|
|||
{
|
||||
if (Engine.Server.Config.Port != options.Port)
|
||||
{
|
||||
Engine.Logger.Info("Overriding port to " + options.Port);
|
||||
Engine.Server.Config.Port = options.Port;
|
||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
{
|
||||
|
|
|
@ -308,9 +308,13 @@ namespace Jackett.Controllers
|
|||
Engine.Server.Config.Port = port;
|
||||
Engine.Server.SaveConfig();
|
||||
|
||||
// On Windows change the url reservations
|
||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
{
|
||||
if (!ServerUtil.IsUserAdministrator())
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
processService.StartProcessAndLog(Application.ExecutablePath, "--ReserveUrls", true);
|
||||
}
|
||||
catch
|
||||
|
@ -322,10 +326,12 @@ namespace Jackett.Controllers
|
|||
jsonReply["error"] = "Failed to acquire admin permissions to reserve the new port.";
|
||||
return Json(jsonReply);
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
serverService.ReserveUrls(true);
|
||||
}
|
||||
}
|
||||
|
||||
(new Thread(() => {
|
||||
Thread.Sleep(500);
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace Jackett.Indexers
|
|||
else
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookieHeader;
|
||||
configSaveData["cookie_header"] = cookieHeader;
|
||||
SaveConfig(configSaveData);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ namespace Jackett.Indexers
|
|||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
cookieHeader = (string)jsonConfig["cookies"];
|
||||
cookieHeader = (string)jsonConfig["cookie_header"];
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ namespace Jackett.Indexers
|
|||
{
|
||||
var config = new ConfigurationDataBasicLogin();
|
||||
config.LoadValuesFromJson(configJson);
|
||||
|
||||
var pairs = new Dictionary<string, string> {
|
||||
{ "username", config.Username.Value },
|
||||
{ "password", config.Password.Value },
|
||||
|
@ -88,7 +87,7 @@ namespace Jackett.Indexers
|
|||
else
|
||||
{
|
||||
var configSaveData = new JObject();
|
||||
configSaveData["cookies"] = cookieHeader;
|
||||
configSaveData["cookie_header"] = cookieHeader;
|
||||
SaveConfig(configSaveData);
|
||||
IsConfigured = true;
|
||||
}
|
||||
|
@ -96,13 +95,9 @@ namespace Jackett.Indexers
|
|||
|
||||
public void LoadFromSavedConfiguration(JToken jsonConfig)
|
||||
{
|
||||
// The old config used an array - just fail to load it
|
||||
if (!(jsonConfig["cookies"] is JArray))
|
||||
{
|
||||
cookieHeader = (string)jsonConfig["cookies"];
|
||||
cookieHeader = (string)jsonConfig["cookie_header"];
|
||||
IsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void FillReleaseInfoFromJson(ReleaseInfo release, JObject r)
|
||||
{
|
||||
|
|
|
@ -24,14 +24,17 @@ namespace Jackett
|
|||
if (Startup.CurlSafe)
|
||||
{
|
||||
builder.RegisterType<UnixSafeCurlWebClient>().As<IWebClient>();
|
||||
Console.WriteLine("Using UnixSafeCurlWebClient");
|
||||
}
|
||||
else if(System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
{
|
||||
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
||||
Console.WriteLine("Using UnixLibCurlWebClient");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.RegisterType<WindowsWebClient>().As<IWebClient>();
|
||||
Console.WriteLine("Using WindowsWebClient");
|
||||
}
|
||||
|
||||
// Register indexers
|
||||
|
|
|
@ -7,6 +7,8 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
@ -47,7 +49,13 @@ namespace Jackett.Services
|
|||
{
|
||||
if (!Directory.Exists(GetAppDataFolder()))
|
||||
{
|
||||
Directory.CreateDirectory(GetAppDataFolder());
|
||||
var dir = Directory.CreateDirectory(GetAppDataFolder());
|
||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
{
|
||||
var access = dir.GetAccessControl();
|
||||
access.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow));
|
||||
Directory.SetAccessControl(GetAppDataFolder(), access);
|
||||
}
|
||||
}
|
||||
|
||||
logger.Debug("App config/log directory: " + GetAppDataFolder());
|
||||
|
@ -57,13 +65,14 @@ namespace Jackett.Services
|
|||
throw new Exception("Could not create settings directory. " + ex.Message);
|
||||
}
|
||||
|
||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
{
|
||||
try
|
||||
{
|
||||
string oldDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Jackett");
|
||||
if (Directory.Exists(oldDir))
|
||||
{
|
||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
{
|
||||
|
||||
// On Windows we need admin permissions to migrate as they were made with admin permissions.
|
||||
if (ServerUtil.IsUserAdministrator())
|
||||
{
|
||||
|
@ -82,36 +91,52 @@ namespace Jackett.Services
|
|||
return;
|
||||
}
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
PerformMigration();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error("ERROR could not migrate settings directory " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PerformMigration()
|
||||
{
|
||||
var oldDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Jackett");
|
||||
if (Directory.Exists(oldDir))
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(oldDir, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
var path = file.Replace(oldDir, "");
|
||||
var destFolder = GetAppDataFolder() + path;
|
||||
if (!Directory.Exists(Path.GetDirectoryName(destFolder)))
|
||||
var destPath = GetAppDataFolder() + path;
|
||||
var destFolder = Path.GetDirectoryName(destPath);
|
||||
if (!Directory.Exists(destFolder))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destFolder));
|
||||
var dir = Directory.CreateDirectory(destFolder);
|
||||
var access = dir.GetAccessControl();
|
||||
access.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow));
|
||||
Directory.SetAccessControl(destFolder, access);
|
||||
}
|
||||
if (!File.Exists(destFolder))
|
||||
if (!File.Exists(destPath))
|
||||
{
|
||||
File.Copy(file, destFolder);
|
||||
File.Copy(file, destPath);
|
||||
// The old files were created when running as admin so make sure they are editable by normal users / services.
|
||||
if (System.Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
{
|
||||
var access = File.GetAccessControl(destPath);
|
||||
access.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow));
|
||||
File.SetAccessControl(destPath, access);
|
||||
}
|
||||
}
|
||||
}
|
||||
Directory.Delete(oldDir, true);
|
||||
}
|
||||
}
|
||||
|
||||
public T GetConfig<T>()
|
||||
{
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace Jackett.Services
|
|||
startInfo.RedirectStandardOutput = false;
|
||||
startInfo.RedirectStandardInput = false;
|
||||
}
|
||||
|
||||
logger.Debug("Running " + startInfo.FileName + " " + startInfo.Arguments);
|
||||
var proc = Process.Start(startInfo);
|
||||
|
||||
if (!asAdmin)
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace Jackett.Utils.Clients
|
|||
}
|
||||
}
|
||||
|
||||
logger.Debug("WebClientByteResult returned " + result.Status);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Jackett.Utils.Clients
|
|||
string stdout = null;
|
||||
await Task.Run(() =>
|
||||
{
|
||||
stdout = processService.StartProcessAndGetOutput(@"C:\Apps\curl.exe", args.ToString(), true);
|
||||
stdout = processService.StartProcessAndGetOutput(System.Environment.OSVersion.Platform == PlatformID.Unix?"curl":"curl.exe", args.ToString(), true);
|
||||
});
|
||||
|
||||
var outputData = File.ReadAllBytes(tempFile);
|
||||
|
@ -126,6 +126,7 @@ namespace Jackett.Utils.Clients
|
|||
dest++;
|
||||
}
|
||||
|
||||
logger.Debug("WebClientByteResult returned " + result.Status);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue