From 2850ff7b8afb2ab1a35c2797f88cef1bc0de8bd9 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sat, 5 Jan 2019 19:12:05 +0100 Subject: Make config path configurable --- Jellyfin.Server/Program.cs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'Jellyfin.Server/Program.cs') diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 2dd4d9af66..d8a7463043 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -124,6 +124,32 @@ namespace Jellyfin.Server } } programDataPath = Path.Combine(programDataPath, "jellyfin"); + Directory.CreateDirectory(programDataPath); + } + + string configPath; + if (options.ContainsOption("-configpath")) + { + configPath = options.GetOption("-configpath"); + } + else + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + configPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + } + else + { + // $XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. + configPath = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME"); + // If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config should be used. + if (string.IsNullOrEmpty(configPath)) + { + configPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share"); + } + } + configPath = Path.Combine(configPath, "jellyfin"); + Directory.CreateDirectory(configPath); } string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR"); @@ -138,7 +164,7 @@ namespace Jellyfin.Server string appPath = AppContext.BaseDirectory; - return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir); + return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configPath); } private static async Task createLogger(IApplicationPaths appPaths) -- cgit v1.2.3