Add env vars JELLYFIN_CONFIG_DIR and JELLYFIN_DATA_PATH

This commit is contained in:
Bond_009 2019-01-05 21:16:47 +01:00
parent 23267bb08f
commit f6d50c411f

View File

@ -102,7 +102,9 @@ namespace Jellyfin.Server
private static ServerApplicationPaths createApplicationPaths(StartupOptions options) private static ServerApplicationPaths createApplicationPaths(StartupOptions options)
{ {
string programDataPath; string programDataPath = Environment.GetEnvironmentVariable("JELLYFIN_DATA_PATH");
if (string.IsNullOrEmpty(programDataPath))
{
if (options.ContainsOption("-programdata")) if (options.ContainsOption("-programdata"))
{ {
programDataPath = options.GetOption("-programdata"); programDataPath = options.GetOption("-programdata");
@ -127,31 +129,35 @@ namespace Jellyfin.Server
// Ensure the dir exists // Ensure the dir exists
Directory.CreateDirectory(programDataPath); Directory.CreateDirectory(programDataPath);
} }
}
string configPath; string configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
if (string.IsNullOrEmpty(configDir))
{
if (options.ContainsOption("-configdir")) if (options.ContainsOption("-configdir"))
{ {
configPath = options.GetOption("-configdir"); configDir = options.GetOption("-configdir");
} }
else else
{ {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
configPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); configDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
} }
else else
{ {
// $XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. // $XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored.
configPath = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME"); configDir = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
// If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config should be used. // If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config should be used.
if (string.IsNullOrEmpty(configPath)) if (string.IsNullOrEmpty(configDir))
{ {
configPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share"); configDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
} }
} }
configPath = Path.Combine(configPath, "jellyfin"); configDir = Path.Combine(configDir, "jellyfin");
// Ensure the dir exists // Ensure the dir exists
Directory.CreateDirectory(configPath); Directory.CreateDirectory(configDir);
}
} }
string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR"); string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
@ -173,7 +179,7 @@ namespace Jellyfin.Server
string appPath = AppContext.BaseDirectory; string appPath = AppContext.BaseDirectory;
return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configPath); return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configDir);
} }
private static async Task createLogger(IApplicationPaths appPaths) private static async Task createLogger(IApplicationPaths appPaths)