Add env vars JELLYFIN_CONFIG_DIR and JELLYFIN_DATA_PATH
This commit is contained in:
parent
23267bb08f
commit
f6d50c411f
|
@ -102,56 +102,62 @@ 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 (options.ContainsOption("-programdata"))
|
if (string.IsNullOrEmpty(programDataPath))
|
||||||
{
|
{
|
||||||
programDataPath = options.GetOption("-programdata");
|
if (options.ContainsOption("-programdata"))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
||||||
{
|
{
|
||||||
programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
programDataPath = options.GetOption("-programdata");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
programDataPath = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
|
|
||||||
// If $XDG_DATA_HOME is either not set or empty, $HOME/.local/share should be used.
|
|
||||||
if (string.IsNullOrEmpty(programDataPath))
|
|
||||||
{
|
{
|
||||||
programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
|
programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
|
||||||
|
programDataPath = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
|
||||||
|
// If $XDG_DATA_HOME is either not set or empty, $HOME/.local/share should be used.
|
||||||
|
if (string.IsNullOrEmpty(programDataPath))
|
||||||
|
{
|
||||||
|
programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
programDataPath = Path.Combine(programDataPath, "jellyfin");
|
||||||
|
// Ensure the dir exists
|
||||||
|
Directory.CreateDirectory(programDataPath);
|
||||||
}
|
}
|
||||||
programDataPath = Path.Combine(programDataPath, "jellyfin");
|
|
||||||
// Ensure the dir exists
|
|
||||||
Directory.CreateDirectory(programDataPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string configPath;
|
string configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
|
||||||
if (options.ContainsOption("-configdir"))
|
if (string.IsNullOrEmpty(configDir))
|
||||||
{
|
{
|
||||||
configPath = options.GetOption("-configdir");
|
if (options.ContainsOption("-configdir"))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
||||||
{
|
{
|
||||||
configPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
configDir = options.GetOption("-configdir");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// $XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored.
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
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");
|
configDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// $XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored.
|
||||||
|
configDir = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
|
||||||
|
// If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config should be used.
|
||||||
|
if (string.IsNullOrEmpty(configDir))
|
||||||
|
{
|
||||||
|
configDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
configDir = Path.Combine(configDir, "jellyfin");
|
||||||
|
// Ensure the dir exists
|
||||||
|
Directory.CreateDirectory(configDir);
|
||||||
}
|
}
|
||||||
configPath = Path.Combine(configPath, "jellyfin");
|
|
||||||
// Ensure the dir exists
|
|
||||||
Directory.CreateDirectory(configPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user