Auto-generate startup.json and add database presets

Introduces automatic creation of a self-documenting startup.json file on first startup, with example path configurations for Linux, Windows, and portable setups. Adds preset database configurations to database.xml for easy switching between SQLite and PostgreSQL. Refactors database config classes for XML serialization compatibility and ensures database.xml is never empty. Comprehensive documentation and migration guides included.
This commit is contained in:
2026-02-25 16:29:08 -05:00
parent c38adfc0f7
commit 69c213f13c
13 changed files with 1759 additions and 5 deletions
+79 -1
View File
@@ -72,7 +72,7 @@ public static class StartupHelpers
/// <summary>
/// Loads startup configuration from startup.json file if it exists.
/// Searches in current directory, then AppContext.BaseDirectory.
/// If no configuration file exists, creates a default one in the application directory.
/// </summary>
/// <returns>Configuration root if file exists, null otherwise.</returns>
private static IConfigurationRoot? LoadStartupConfiguration()
@@ -107,9 +107,87 @@ public static class StartupHelpers
}
}
// No configuration file found - create a default one
CreateDefaultStartupConfiguration();
return null;
}
/// <summary>
/// Creates a default startup.json configuration file with example paths commented out.
/// </summary>
private static void CreateDefaultStartupConfiguration()
{
const string ConfigFileName = "startup.json";
// Determine the best location for the configuration file
// Priority: Current directory (for portable installations) > AppContext.BaseDirectory
var configPath = Path.Combine(Directory.GetCurrentDirectory(), ConfigFileName);
try
{
var defaultConfig = new
{
_comment = "Jellyfin Startup Configuration - Configure path locations for Jellyfin data, logs, cache, and more.",
_documentation = "See FILE_BASED_STARTUP_CONFIG.md for complete documentation",
_priority = "Command-line options > Environment variables > This file > Defaults",
Paths = new
{
DataDir = (string?)null,
ConfigDir = (string?)null,
CacheDir = (string?)null,
LogDir = (string?)null,
TempDir = (string?)null,
WebDir = (string?)null
},
Examples = new
{
_comment = "Example configurations below - remove this Examples section when customizing",
Linux = new
{
DataDir = "/var/lib/jellyfin",
ConfigDir = "/etc/jellyfin",
CacheDir = "/var/cache/jellyfin",
LogDir = "/var/log/jellyfin",
TempDir = "/var/tmp/jellyfin",
WebDir = "/usr/share/jellyfin/web"
},
Windows = new
{
DataDir = "C:\\ProgramData\\Jellyfin\\data",
ConfigDir = "C:\\ProgramData\\Jellyfin\\config",
CacheDir = "D:\\Cache\\Jellyfin",
LogDir = "C:\\ProgramData\\Jellyfin\\logs",
TempDir = "D:\\Temp\\Jellyfin",
WebDir = "C:\\Program Files\\Jellyfin\\web"
},
Portable = new
{
DataDir = "./data",
ConfigDir = "./config",
CacheDir = "./cache",
LogDir = "./logs",
TempDir = "./temp",
WebDir = "./web"
}
}
};
var json = System.Text.Json.JsonSerializer.Serialize(defaultConfig, new System.Text.Json.JsonSerializerOptions
{
WriteIndented = true
});
File.WriteAllText(configPath, json);
Console.WriteLine($"Created default startup configuration at: {configPath}");
Console.WriteLine("You can customize this file to set default paths for Jellyfin.");
}
catch (Exception ex)
{
Console.WriteLine($"Warning: Could not create default startup configuration: {ex.Message}");
}
}
/// <summary>
/// Create the data, config and log paths from the variety of inputs(command line args,
/// environment variables) or decide on what default to use. For Windows it's %AppPath%