diff options
Diffstat (limited to 'Jellyfin.Server/Program.cs')
| -rw-r--r-- | Jellyfin.Server/Program.cs | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index acbe5c714..51ad53749 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -17,8 +17,8 @@ using Emby.Server.Implementations.Networking; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Drawing; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Globalization; +using MediaBrowser.Model.IO; using MediaBrowser.Model.System; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; @@ -45,7 +45,8 @@ namespace Jellyfin.Server Console.WriteLine(version.ToString()); } - ServerApplicationPaths appPaths = createApplicationPaths(options); + ServerApplicationPaths appPaths = CreateApplicationPaths(options); + // $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", appPaths.LogDirectoryPath); await createLogger(appPaths); @@ -130,7 +131,7 @@ namespace Jellyfin.Server } } - private static ServerApplicationPaths createApplicationPaths(StartupOptions options) + private static ServerApplicationPaths CreateApplicationPaths(StartupOptions options) { string programDataPath = Environment.GetEnvironmentVariable("JELLYFIN_DATA_PATH"); if (string.IsNullOrEmpty(programDataPath)) @@ -155,12 +156,21 @@ namespace Jellyfin.Server programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share"); } } + programDataPath = Path.Combine(programDataPath, "jellyfin"); - // Ensure the dir exists - Directory.CreateDirectory(programDataPath); } } + if (string.IsNullOrEmpty(programDataPath)) + { + Console.WriteLine("Cannot continue without path to program data folder (try -programdata)"); + Environment.Exit(1); + } + else + { + Directory.CreateDirectory(programDataPath); + } + string configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR"); if (string.IsNullOrEmpty(configDir)) { @@ -175,6 +185,11 @@ namespace Jellyfin.Server } } + if (configDir != null) + { + Directory.CreateDirectory(configDir); + } + string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR"); if (string.IsNullOrEmpty(logDir)) { @@ -189,6 +204,11 @@ namespace Jellyfin.Server } } + if (logDir != null) + { + Directory.CreateDirectory(logDir); + } + string appPath = AppContext.BaseDirectory; return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configDir); @@ -258,7 +278,8 @@ namespace Jellyfin.Server return new NullImageEncoder(); } - private static MediaBrowser.Model.System.OperatingSystem getOperatingSystem() { + private static MediaBrowser.Model.System.OperatingSystem getOperatingSystem() + { switch (Environment.OSVersion.Platform) { case PlatformID.MacOSX: @@ -267,22 +288,22 @@ namespace Jellyfin.Server return MediaBrowser.Model.System.OperatingSystem.Windows; case PlatformID.Unix: default: - { - string osDescription = RuntimeInformation.OSDescription; - if (osDescription.Contains("linux", StringComparison.OrdinalIgnoreCase)) - { - return MediaBrowser.Model.System.OperatingSystem.Linux; - } - else if (osDescription.Contains("darwin", StringComparison.OrdinalIgnoreCase)) - { - return MediaBrowser.Model.System.OperatingSystem.OSX; - } - else if (osDescription.Contains("bsd", StringComparison.OrdinalIgnoreCase)) { - return MediaBrowser.Model.System.OperatingSystem.BSD; + string osDescription = RuntimeInformation.OSDescription; + if (osDescription.Contains("linux", StringComparison.OrdinalIgnoreCase)) + { + return MediaBrowser.Model.System.OperatingSystem.Linux; + } + else if (osDescription.Contains("darwin", StringComparison.OrdinalIgnoreCase)) + { + return MediaBrowser.Model.System.OperatingSystem.OSX; + } + else if (osDescription.Contains("bsd", StringComparison.OrdinalIgnoreCase)) + { + return MediaBrowser.Model.System.OperatingSystem.BSD; + } + throw new Exception($"Can't resolve OS with description: '{osDescription}'"); } - throw new Exception($"Can't resolve OS with description: '{osDescription}'"); - } } } @@ -320,7 +341,7 @@ namespace Jellyfin.Server } else { - commandLineArgsString = string .Join(" ", + commandLineArgsString = string.Join(" ", Environment.GetCommandLineArgs() .Skip(1) .Select(NormalizeCommandLineArgument) |
