StartupOptions.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using CommandLine;
  4. using Emby.Server.Implementations;
  5. using Emby.Server.Implementations.EntryPoints;
  6. using Emby.Server.Implementations.Udp;
  7. using Emby.Server.Implementations.Updates;
  8. using MediaBrowser.Controller.Extensions;
  9. namespace Jellyfin.Server
  10. {
  11. /// <summary>
  12. /// Class used by CommandLine package when parsing the command line arguments.
  13. /// </summary>
  14. public class StartupOptions : IStartupOptions
  15. {
  16. /// <summary>
  17. /// Gets or sets the path to the data directory.
  18. /// </summary>
  19. /// <value>The path to the data directory.</value>
  20. [Option('d', "datadir", Required = false, HelpText = "Path to use for the data folder (database files, etc.).")]
  21. public string? DataDir { get; set; }
  22. /// <summary>
  23. /// Gets or sets a value indicating whether the server should not host the web client.
  24. /// </summary>
  25. [Option("nowebclient", Required = false, HelpText = "Indicates that the web server should not host the web client.")]
  26. public bool NoWebClient { get; set; }
  27. /// <summary>
  28. /// Gets or sets the path to the web directory.
  29. /// </summary>
  30. /// <value>The path to the web directory.</value>
  31. [Option('w', "webdir", Required = false, HelpText = "Path to the Jellyfin web UI resources.")]
  32. public string? WebDir { get; set; }
  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. /// <summary>
  40. /// Gets or sets the path to the config directory.
  41. /// </summary>
  42. /// <value>The path to the config directory.</value>
  43. [Option('c', "configdir", Required = false, HelpText = "Path to use for configuration data (user settings and pictures).")]
  44. public string? ConfigDir { get; set; }
  45. /// <summary>
  46. /// Gets or sets the path to the log directory.
  47. /// </summary>
  48. /// <value>The path to the log directory.</value>
  49. [Option('l', "logdir", Required = false, HelpText = "Path to use for writing log files.")]
  50. public string? LogDir { get; set; }
  51. /// <inheritdoc />
  52. [Option("ffmpeg", Required = false, HelpText = "Path to external FFmpeg executable to use in place of default found in PATH.")]
  53. public string? FFmpegPath { get; set; }
  54. /// <inheritdoc />
  55. [Option("service", Required = false, HelpText = "Run as headless service.")]
  56. public bool IsService { get; set; }
  57. /// <inheritdoc />
  58. [Option("noautorunwebapp", Required = false, HelpText = "Run headless if startup wizard is complete.")]
  59. public bool NoAutoRunWebApp { get; set; }
  60. /// <inheritdoc />
  61. [Option("package-name", Required = false, HelpText = "Used when packaging Jellyfin (example, synology).")]
  62. public string? PackageName { get; set; }
  63. /// <inheritdoc />
  64. [Option("restartpath", Required = false, HelpText = "Path to restart script.")]
  65. public string? RestartPath { get; set; }
  66. /// <inheritdoc />
  67. [Option("restartargs", Required = false, HelpText = "Arguments for restart script.")]
  68. public string? RestartArgs { get; set; }
  69. /// <inheritdoc />
  70. [Option("plugin-manifest-url", Required = false, HelpText = "A custom URL for the plugin repository JSON manifest")]
  71. public string? PluginManifestUrl { get; set; }
  72. /// <inheritdoc />
  73. [Option("published-server-url", Required = false, HelpText = "Jellyfin Server URL to publish via auto discover process")]
  74. public Uri? PublishedServerUrl { get; set; }
  75. /// <summary>
  76. /// Gets the command line options as a dictionary that can be used in the .NET configuration system.
  77. /// </summary>
  78. /// <returns>The configuration dictionary.</returns>
  79. public Dictionary<string, string> ConvertToConfig()
  80. {
  81. var config = new Dictionary<string, string>();
  82. if (PluginManifestUrl != null)
  83. {
  84. config.Add(InstallationManager.PluginManifestUrlKey, PluginManifestUrl);
  85. }
  86. if (NoWebClient)
  87. {
  88. config.Add(ConfigurationExtensions.HostWebClientKey, bool.FalseString);
  89. }
  90. if (PublishedServerUrl != null)
  91. {
  92. config.Add(UdpServer.AddressOverrideConfigKey, PublishedServerUrl.ToString());
  93. }
  94. return config;
  95. }
  96. }
  97. }