Adds a new section "Scripting" in the server UI where PowerShell modules can be defined. These can be used for defining a library of functions that can be used in any script. These modules are automatically synced to the launcher and imported upon script execution.
33 lines
No EOL
1.1 KiB
C#
33 lines
No EOL
1.1 KiB
C#
using LANCommander.SDK;
|
|
using LANCommander.Server.Services.Models;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace LANCommander.Server.Startup;
|
|
|
|
public static class Filesystem
|
|
{
|
|
public static WebApplication PrepareDirectories(this WebApplication app)
|
|
{
|
|
var settings = app.Services.GetRequiredService<IOptions<Settings.Settings>>();
|
|
var logger = app.Services.GetRequiredService<ILogger<Program>>();
|
|
|
|
logger.LogDebug("Ensuring required directories exist");
|
|
|
|
IEnumerable<string> directories = [
|
|
settings.Value.Server.Update.StoragePath,
|
|
settings.Value.Server.Launcher.StoragePath,
|
|
settings.Value.Server.Backups.StoragePath,
|
|
settings.Value.Server.Scripts.Snippets.StoragePath,
|
|
settings.Value.Server.Scripts.Modules.StoragePath,
|
|
];
|
|
|
|
foreach (var directory in directories)
|
|
{
|
|
logger.LogDebug("Ensuring directory {Directory} exists", directory);
|
|
if (!Directory.Exists(directory))
|
|
Directory.CreateDirectory(directory);
|
|
}
|
|
|
|
return app;
|
|
}
|
|
} |