aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Server')
-rw-r--r--Jellyfin.Server/Jellyfin.Server.csproj1
-rw-r--r--Jellyfin.Server/Program.cs21
-rw-r--r--Jellyfin.Server/StartupOptions.cs47
3 files changed, 58 insertions, 11 deletions
diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj
index 5a4bf5149..1f72de86d 100644
--- a/Jellyfin.Server/Jellyfin.Server.csproj
+++ b/Jellyfin.Server/Jellyfin.Server.csproj
@@ -32,6 +32,7 @@
</PropertyGroup>
<ItemGroup>
+ <PackageReference Include="CommandLineParser" Version="2.4.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 2f7edee65..905cf3aa0 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -6,8 +6,10 @@ using System.Net;
using System.Net.Security;
using System.Reflection;
using System.Runtime.InteropServices;
+using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
+using CommandLine;
using Emby.Drawing;
using Emby.Server.Implementations;
using Emby.Server.Implementations.EnvironmentInfo;
@@ -26,9 +28,6 @@ using ILogger = Microsoft.Extensions.Logging.ILogger;
namespace Jellyfin.Server
{
- using CommandLine;
- using System.Text.RegularExpressions;
-
public static class Program
{
private static readonly CancellationTokenSource _tokenSource = new CancellationTokenSource();
@@ -41,8 +40,8 @@ namespace Jellyfin.Server
// For backwards compatibility.
// Modify any input arguments now which start with single-hyphen to POSIX standard
// double-hyphen to allow parsing by CommandLineParser package.
- var pattern = @"^(-[^-\s]{2})"; // Match -xx, not -x, not --xx, not xx
- var substitution = @"-$1"; // Prepend with additional single-hyphen
+ const string pattern = @"^(-[^-\s]{2})"; // Match -xx, not -x, not --xx, not xx
+ const string substitution = @"-$1"; // Prepend with additional single-hyphen
var regex = new Regex(pattern);
for (var i = 0; i < args.Length; i++)
@@ -152,9 +151,9 @@ namespace Jellyfin.Server
string programDataPath = Environment.GetEnvironmentVariable("JELLYFIN_DATA_PATH");
if (string.IsNullOrEmpty(programDataPath))
{
- if (options.PathData != null)
+ if (options.DataDir != null)
{
- programDataPath = options.PathData;
+ programDataPath = options.DataDir;
}
else
{
@@ -190,9 +189,9 @@ namespace Jellyfin.Server
string configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
if (string.IsNullOrEmpty(configDir))
{
- if (options.PathConfig != null)
+ if (options.ConfigDir != null)
{
- configDir = options.PathConfig;
+ configDir = options.ConfigDir;
}
else
{
@@ -209,9 +208,9 @@ namespace Jellyfin.Server
string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
if (string.IsNullOrEmpty(logDir))
{
- if (options.PathLog != null)
+ if (options.LogDir != null)
{
- logDir = options.PathLog;
+ logDir = options.LogDir;
}
else
{
diff --git a/Jellyfin.Server/StartupOptions.cs b/Jellyfin.Server/StartupOptions.cs
new file mode 100644
index 000000000..97fcb633a
--- /dev/null
+++ b/Jellyfin.Server/StartupOptions.cs
@@ -0,0 +1,47 @@
+using CommandLine;
+using Emby.Server.Implementations.ParsedStartupOptions;
+
+namespace Jellyfin.Server
+{
+ /// <summary>
+ /// Class used by CommandLine package when parsing the command line arguments.
+ /// </summary>
+ public class StartupOptions : IStartupOptions
+ {
+ [Option('d', "datadir", Required = false, HelpText = "Path to use for the data folder (databases files etc.).")]
+ public string DataDir { get; set; }
+
+ [Option('c', "configdir", Required = false, HelpText = "Path to use for config data (user policies and puctures).")]
+ public string ConfigDir { get; set; }
+
+ [Option('l', "logdir", Required = false, HelpText = "Path to use for writing log files.")]
+ public string LogDir { get; set; }
+
+ [Option("ffmpeg", Required = false, HelpText = "Path to external FFmpeg exe to use in place of built-in.")]
+ public string FFmpegPath { get; set; }
+
+ [Option("ffprobe", Required = false, HelpText = "ffmpeg and ffprobe switches must be supplied together.")]
+ public string FFprobePath { get; set; }
+
+ [Option("service", Required = false, HelpText = "Run as headless service.")]
+ public bool IsService { get; set; }
+
+ [Option("noautorunwebapp", Required = false, HelpText = "Run headless if startup wizard is complete.")]
+ public bool AutoRunWebApp { get => !NoautoRunWebApp; set => NoautoRunWebApp = value; }
+
+ [Option("package-name", Required = false, HelpText = "Used when packaging Jellyfin (example, synology).")]
+ public string PackageName { get; set; }
+
+ [Option("restartpath", Required = false, HelpText = "Path to reset script.")]
+ public string RestartPath { get; set; }
+
+ [Option("restartargs", Required = false, HelpText = "Arguments for restart script.")]
+ public string RestartArgs { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to run not run the web app.
+ /// Command line switch is --noautorunwebapp, which we store privately here, but provide inverse (AutoRunWebApp) for users.
+ /// </summary>
+ private bool NoautoRunWebApp { get; set; }
+ }
+}