StartupOptions.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System.Collections.Generic;
  2. using CommandLine;
  3. using Emby.Server.Implementations;
  4. using Emby.Server.Implementations.Udp;
  5. using MediaBrowser.Controller.Extensions;
  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. /// <summary>
  20. /// Gets or sets a value indicating whether the server should not host the web client.
  21. /// </summary>
  22. [Option("nowebclient", Required = false, HelpText = "Indicates that the web server should not host the web client.")]
  23. public bool NoWebClient { get; set; }
  24. /// <summary>
  25. /// Gets or sets the path to the web directory.
  26. /// </summary>
  27. /// <value>The path to the web directory.</value>
  28. [Option('w', "webdir", Required = false, HelpText = "Path to the Jellyfin web UI resources.")]
  29. public string? WebDir { get; set; }
  30. /// <summary>
  31. /// Gets or sets the path to the cache directory.
  32. /// </summary>
  33. /// <value>The path to the cache directory.</value>
  34. [Option('C', "cachedir", Required = false, HelpText = "Path to use for caching.")]
  35. public string? CacheDir { get; set; }
  36. /// <summary>
  37. /// Gets or sets the path to the config directory.
  38. /// </summary>
  39. /// <value>The path to the config directory.</value>
  40. [Option('c', "configdir", Required = false, HelpText = "Path to use for configuration data (user settings and pictures).")]
  41. public string? ConfigDir { get; set; }
  42. /// <summary>
  43. /// Gets or sets the path to the log directory.
  44. /// </summary>
  45. /// <value>The path to the log directory.</value>
  46. [Option('l', "logdir", Required = false, HelpText = "Path to use for writing log files.")]
  47. public string? LogDir { get; set; }
  48. /// <inheritdoc />
  49. [Option("ffmpeg", Required = false, HelpText = "Path to external FFmpeg executable to use in place of default found in PATH.")]
  50. public string? FFmpegPath { get; set; }
  51. /// <inheritdoc />
  52. [Option("service", Required = false, HelpText = "Run as headless service.")]
  53. public bool IsService { get; set; }
  54. /// <inheritdoc />
  55. [Option("package-name", Required = false, HelpText = "Used when packaging Jellyfin (example, synology).")]
  56. public string? PackageName { get; set; }
  57. /// <inheritdoc />
  58. [Option("restartpath", Required = false, HelpText = "Path to restart script.")]
  59. public string? RestartPath { get; set; }
  60. /// <inheritdoc />
  61. [Option("restartargs", Required = false, HelpText = "Arguments for restart script.")]
  62. public string? RestartArgs { get; set; }
  63. /// <inheritdoc />
  64. [Option("published-server-url", Required = false, HelpText = "Jellyfin Server URL to publish via auto discover process")]
  65. public string? PublishedServerUrl { get; set; }
  66. /// <summary>
  67. /// Gets the command line options as a dictionary that can be used in the .NET configuration system.
  68. /// </summary>
  69. /// <returns>The configuration dictionary.</returns>
  70. public Dictionary<string, string> ConvertToConfig()
  71. {
  72. var config = new Dictionary<string, string>();
  73. if (NoWebClient)
  74. {
  75. config.Add(ConfigurationExtensions.HostWebClientKey, bool.FalseString);
  76. }
  77. if (PublishedServerUrl != null)
  78. {
  79. config.Add(UdpServer.AddressOverrideConfigKey, PublishedServerUrl);
  80. }
  81. if (FFmpegPath != null)
  82. {
  83. config.Add(ConfigurationExtensions.FfmpegPathKey, FFmpegPath);
  84. }
  85. return config;
  86. }
  87. }
  88. }