StartupOptions.cs 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System.Collections.Generic;
  2. using System.Globalization;
  3. using CommandLine;
  4. using Emby.Server.Implementations;
  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("noautorunwebapp", Required = false, HelpText = "Run headless if startup wizard is complete.")]
  56. public bool NoAutoRunWebApp { get; set; }
  57. /// <inheritdoc />
  58. [Option("package-name", Required = false, HelpText = "Used when packaging Jellyfin (example, synology).")]
  59. public string? PackageName { get; set; }
  60. /// <inheritdoc />
  61. [Option("restartpath", Required = false, HelpText = "Path to restart script.")]
  62. public string? RestartPath { get; set; }
  63. /// <inheritdoc />
  64. [Option("restartargs", Required = false, HelpText = "Arguments for restart script.")]
  65. public string? RestartArgs { 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. return config;
  78. }
  79. }
  80. }