50 lines
2.5 KiB
C#
50 lines
2.5 KiB
C#
using MoonlightServers.Daemon.Models;
|
|
|
|
namespace MoonlightServers.Daemon.Services;
|
|
|
|
public class ServerConfigurationService
|
|
{
|
|
public async Task<RuntimeConfiguration> GetRuntimeConfigurationAsync(string uuid)
|
|
{
|
|
return new RuntimeConfiguration(
|
|
new RuntimeLimitsConfig(400, null, 4096, null),
|
|
new RuntimeStorageConfig("local", [], 10240),
|
|
new RuntimeTemplateConfig(
|
|
"ghcr.io/pterodactyl/yolks:java_21",
|
|
"java -jar -Xmx{{SERVER_MEMORY}}M server.jar",
|
|
"stop",
|
|
["Done"]
|
|
),
|
|
new RuntimeNetworkConfig(
|
|
[],
|
|
null,
|
|
null,
|
|
new RuntimePortConfig("0.0.0.0", 25565),
|
|
[
|
|
new RuntimePortConfig("0.0.0.0", 25565)
|
|
]
|
|
),
|
|
new RuntimeEnvironmentConfig(
|
|
new Dictionary<string, string>()
|
|
{
|
|
{ "testy", "ytset" }
|
|
},
|
|
new Dictionary<string, string>()
|
|
{
|
|
{ "SERVER_MEMORY", "4096" },
|
|
{"MINECRAFT_VERSION", "latest"},
|
|
{"SERVER_JARFILE", "server.jar"}
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
public async Task<InstallConfiguration> GetInstallConfigurationAsync(string uuid)
|
|
{
|
|
return new InstallConfiguration(
|
|
"bash",
|
|
"installer",
|
|
"#!/bin/bash\n# Paper Installation Script\n#\necho -e \"Started Installation\"\n\n# Server Files: /mnt/server\nPROJECT=paper\n\nif [ \"${MINECRAFT_VERSION}\" == \"latest\" ]; then\n LATEST_VERSION=$(curl -s https://api.papermc.io/v2/projects/${PROJECT} | jq -r '.versions[-1]')\n MINECRAFT_VERSION=${LATEST_VERSION}\nfi\n\nGET_BUILD=$(curl -s https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION} | jq -r '.builds[-1]')\nBUILD_NUMBER=${GET_BUILD}\n\n\nJAR_NAME=${PROJECT}-${MINECRAFT_VERSION}-${BUILD_NUMBER}.jar\n\necho \"Version being downloaded\"\necho -e \"MC Version: ${MINECRAFT_VERSION}\"\necho -e \"Build: ${BUILD_NUMBER}\"\necho -e \"JAR Name of Build: ${JAR_NAME}\"\nDOWNLOAD_URL=https://api.papermc.io/v2/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds/${BUILD_NUMBER}/downloads/${JAR_NAME}\n\ncd /mnt/server\n\necho -e \"Running curl -o ${SERVER_JARFILE} ${DOWNLOAD_URL}\"\n\nif [ -f ${SERVER_JARFILE} ]; then\n mv ${SERVER_JARFILE} ${SERVER_JARFILE}.old\nfi\n\ncurl -o ${SERVER_JARFILE} ${DOWNLOAD_URL}\n"
|
|
);
|
|
}
|
|
} |