Merge pull request #428 from Bond-009/config
Make config path configurable
This commit is contained in:
commit
7630e58218
|
@ -12,11 +12,16 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
|
/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected BaseApplicationPaths(string programDataPath, string appFolderPath, string logDirectoryPath)
|
protected BaseApplicationPaths(
|
||||||
|
string programDataPath,
|
||||||
|
string appFolderPath,
|
||||||
|
string logDirectoryPath = null,
|
||||||
|
string configurationDirectoryPath = null)
|
||||||
{
|
{
|
||||||
ProgramDataPath = programDataPath;
|
ProgramDataPath = programDataPath;
|
||||||
ProgramSystemPath = appFolderPath;
|
ProgramSystemPath = appFolderPath;
|
||||||
LogDirectoryPath = logDirectoryPath;
|
LogDirectoryPath = logDirectoryPath;
|
||||||
|
ConfigurationDirectoryPath = configurationDirectoryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ProgramDataPath { get; private set; }
|
public string ProgramDataPath { get; private set; }
|
||||||
|
@ -134,6 +139,11 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The _config directory
|
||||||
|
/// </summary>
|
||||||
|
private string _configurationDirectoryPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the path to the application configuration root directory
|
/// Gets the path to the application configuration root directory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -142,7 +152,18 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Path.Combine(ProgramDataPath, "config");
|
if (string.IsNullOrEmpty(_configurationDirectoryPath))
|
||||||
|
{
|
||||||
|
_configurationDirectoryPath = Path.Combine(ProgramDataPath, "config");
|
||||||
|
|
||||||
|
Directory.CreateDirectory(_configurationDirectoryPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _configurationDirectoryPath;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_configurationDirectoryPath = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,13 @@ namespace Emby.Server.Implementations
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
|
/// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath, string logDirectoryPath = null)
|
public ServerApplicationPaths(
|
||||||
: base(programDataPath, appFolderPath, logDirectoryPath)
|
string programDataPath,
|
||||||
|
string appFolderPath,
|
||||||
|
string applicationResourcesPath,
|
||||||
|
string logDirectoryPath = null,
|
||||||
|
string configurationDirectoryPath = null)
|
||||||
|
: base(programDataPath, appFolderPath, logDirectoryPath, configurationDirectoryPath)
|
||||||
{
|
{
|
||||||
ApplicationResourcesPath = applicationResourcesPath;
|
ApplicationResourcesPath = applicationResourcesPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
||||||
|
@ -124,21 +126,60 @@ namespace Jellyfin.Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
programDataPath = Path.Combine(programDataPath, "jellyfin");
|
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");
|
string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
|
||||||
if (string.IsNullOrEmpty(logDir))
|
if (string.IsNullOrEmpty(logDir))
|
||||||
|
{
|
||||||
|
if (options.ContainsOption("-logdir"))
|
||||||
|
{
|
||||||
|
logDir = options.GetOption("-logdir");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
logDir = Path.Combine(programDataPath, "logs");
|
logDir = Path.Combine(programDataPath, "logs");
|
||||||
// Ensure logDir exists
|
// Ensure the dir exists
|
||||||
Directory.CreateDirectory(logDir);
|
Directory.CreateDirectory(logDir);
|
||||||
|
}
|
||||||
// $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager
|
// $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager
|
||||||
Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", logDir);
|
Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", logDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
string appPath = AppContext.BaseDirectory;
|
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)
|
private static async Task createLogger(IApplicationPaths appPaths)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user