|
|
|
@ -102,7 +102,9 @@ namespace Jellyfin.Server
|
|
|
|
|
|
|
|
|
|
private static ServerApplicationPaths createApplicationPaths(StartupOptions options)
|
|
|
|
|
{
|
|
|
|
|
string programDataPath;
|
|
|
|
|
string programDataPath = Environment.GetEnvironmentVariable("JELLYFIN_DATA_PATH");
|
|
|
|
|
if (string.IsNullOrEmpty(programDataPath))
|
|
|
|
|
{
|
|
|
|
|
if (options.ContainsOption("-programdata"))
|
|
|
|
|
{
|
|
|
|
|
programDataPath = options.GetOption("-programdata");
|
|
|
|
@ -124,21 +126,60 @@ namespace Jellyfin.Server
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
programDataPath = Path.Combine(programDataPath, "jellyfin");
|
|
|
|
|
// Ensure the dir exists
|
|
|
|
|
Directory.CreateDirectory(programDataPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
|
|
|
|
|
if (string.IsNullOrEmpty(configDir))
|
|
|
|
|
{
|
|
|
|
|
if (options.ContainsOption("-configdir"))
|
|
|
|
|
{
|
|
|
|
|
configDir = options.GetOption("-configdir");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
|
|
|
|
|
if (string.IsNullOrEmpty(logDir))
|
|
|
|
|
{
|
|
|
|
|
if (options.ContainsOption("-logdir"))
|
|
|
|
|
{
|
|
|
|
|
logDir = options.GetOption("-logdir");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
logDir = Path.Combine(programDataPath, "logs");
|
|
|
|
|
// Ensure logDir exists
|
|
|
|
|
// Ensure the dir exists
|
|
|
|
|
Directory.CreateDirectory(logDir);
|
|
|
|
|
}
|
|
|
|
|
// $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager
|
|
|
|
|
Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", logDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string appPath = AppContext.BaseDirectory;
|
|
|
|
|
|
|
|
|
|
return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir);
|
|
|
|
|
return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static async Task createLogger(IApplicationPaths appPaths)
|
|
|
|
|