Started implementing server installation

This commit is contained in:
2025-02-13 21:23:35 +01:00
parent f45699f300
commit 761ab455f0
11 changed files with 179 additions and 19 deletions

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using MoonCore.Exceptions;
using MoonCore.Extended.Abstractions;
using MoonCore.Models;
using MoonlightServers.ApiServer.Database.Entities;
@@ -96,4 +97,23 @@ public class RemoteServersController : Controller
TotalPages = total == 0 ? 0 : total / pageSize
};
}
[HttpGet("{id:int}/install")]
public async Task<ServerInstallDataResponse> GetInstall([FromRoute] int id)
{
var server = await ServerRepository
.Get()
.Include(x => x.Star)
.FirstOrDefaultAsync(x => x.Id == id);
if (server == null)
throw new HttpApiException("No server with this id found", 404);
return new ServerInstallDataResponse()
{
Script = server.Star.InstallScript,
DockerImage = server.Star.InstallDockerImage,
Shell = server.Star.InstallShell
};
}
}