| | | 1 | | using System.Collections.Generic; |
| | | 2 | | using CommandLine; |
| | | 3 | | using Emby.Server.Implementations; |
| | | 4 | | using static MediaBrowser.Controller.Extensions.ConfigurationExtensions; |
| | | 5 | | |
| | | 6 | | namespace Jellyfin.Server |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Class used by CommandLine package when parsing the command line arguments. |
| | | 10 | | /// </summary> |
| | | 11 | | public class StartupOptions : IStartupOptions |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets or sets the path to the data directory. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <value>The path to the data directory.</value> |
| | | 17 | | [Option('d', "datadir", Required = false, HelpText = "Path to use for the data folder (database files, etc.).")] |
| | | 18 | | public string? DataDir { get; set; } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Gets or sets a value indicating whether the server should not host the web client. |
| | | 22 | | /// </summary> |
| | | 23 | | [Option("nowebclient", Required = false, HelpText = "Indicates that the web server should not host the web clien |
| | | 24 | | public bool NoWebClient { get; set; } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Gets or sets the path to the web directory. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <value>The path to the web directory.</value> |
| | | 30 | | [Option('w', "webdir", Required = false, HelpText = "Path to the Jellyfin web UI resources.")] |
| | | 31 | | public string? WebDir { get; set; } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Gets or sets the path to the cache directory. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <value>The path to the cache directory.</value> |
| | | 37 | | [Option('C', "cachedir", Required = false, HelpText = "Path to use for caching.")] |
| | | 38 | | public string? CacheDir { get; set; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Gets or sets the path to the config directory. |
| | | 42 | | /// </summary> |
| | | 43 | | /// <value>The path to the config directory.</value> |
| | | 44 | | [Option('c', "configdir", Required = false, HelpText = "Path to use for configuration data (user settings and pi |
| | | 45 | | public string? ConfigDir { get; set; } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Gets or sets the path to the log directory. |
| | | 49 | | /// </summary> |
| | | 50 | | /// <value>The path to the log directory.</value> |
| | | 51 | | [Option('l', "logdir", Required = false, HelpText = "Path to use for writing log files.")] |
| | | 52 | | public string? LogDir { get; set; } |
| | | 53 | | |
| | | 54 | | /// <inheritdoc /> |
| | | 55 | | [Option("ffmpeg", Required = false, HelpText = "Path to external FFmpeg executable to use in place of default fo |
| | | 56 | | public string? FFmpegPath { get; set; } |
| | | 57 | | |
| | | 58 | | /// <inheritdoc /> |
| | | 59 | | [Option("service", Required = false, HelpText = "Run as headless service.")] |
| | | 60 | | public bool IsService { get; set; } |
| | | 61 | | |
| | | 62 | | /// <inheritdoc /> |
| | | 63 | | [Option("package-name", Required = false, HelpText = "Used when packaging Jellyfin (example, synology).")] |
| | | 64 | | public string? PackageName { get; set; } |
| | | 65 | | |
| | | 66 | | /// <inheritdoc /> |
| | | 67 | | [Option("published-server-url", Required = false, HelpText = "Jellyfin Server URL to publish via auto discover p |
| | | 68 | | public string? PublishedServerUrl { get; set; } |
| | | 69 | | |
| | | 70 | | /// <summary> |
| | | 71 | | /// Gets or sets a value indicating whether the server should not detect network status change. |
| | | 72 | | /// </summary> |
| | | 73 | | [Option("nonetchange", Required = false, HelpText = "Indicates that the server should not detect network status |
| | | 74 | | public bool NoDetectNetworkChange { get; set; } |
| | | 75 | | |
| | | 76 | | /// <summary> |
| | | 77 | | /// Gets or sets the path to an jellyfin backup archive to restore the application to. |
| | | 78 | | /// </summary> |
| | | 79 | | [Option("restore-archive", Required = false, HelpText = "Path to a Jellyfin backup archive to restore from")] |
| | | 80 | | public string? RestoreArchive { get; set; } |
| | | 81 | | |
| | | 82 | | /// <summary> |
| | | 83 | | /// Gets the command line options as a dictionary that can be used in the .NET configuration system. |
| | | 84 | | /// </summary> |
| | | 85 | | /// <returns>The configuration dictionary.</returns> |
| | | 86 | | public Dictionary<string, string?> ConvertToConfig() |
| | | 87 | | { |
| | 42 | 88 | | var config = new Dictionary<string, string?>(); |
| | | 89 | | |
| | 42 | 90 | | if (NoWebClient) |
| | | 91 | | { |
| | 0 | 92 | | config.Add(HostWebClientKey, bool.FalseString); |
| | | 93 | | } |
| | | 94 | | |
| | 42 | 95 | | if (PublishedServerUrl is not null) |
| | | 96 | | { |
| | 0 | 97 | | config.Add(AddressOverrideKey, PublishedServerUrl); |
| | | 98 | | } |
| | | 99 | | |
| | 42 | 100 | | if (FFmpegPath is not null) |
| | | 101 | | { |
| | 0 | 102 | | config.Add(FfmpegPathKey, FFmpegPath); |
| | | 103 | | } |
| | | 104 | | |
| | 42 | 105 | | if (NoDetectNetworkChange) |
| | | 106 | | { |
| | 0 | 107 | | config.Add(DetectNetworkChangeKey, bool.FalseString); |
| | | 108 | | } |
| | | 109 | | |
| | 42 | 110 | | return config; |
| | | 111 | | } |
| | | 112 | | } |
| | | 113 | | } |