mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2025-04-03 14:38:36 -04:00
Compare commits
3 Commits
28e678bce9
...
b6a73df815
Author | SHA1 | Date | |
---|---|---|---|
b6a73df815 | |||
cbecb21ea3 | |||
1a3804e865 |
@ -10,6 +10,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\files\template\Dockerfile" />
|
||||
<EmbeddedResource Include="Resources\files\template\entrypoint" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -657,6 +657,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
public ActionResult<bool> Reset(int wId)
|
||||
{
|
||||
Console.WriteLine($"Resetting world {wId}");
|
||||
|
||||
var world = _context.Worlds.Find(wId);
|
||||
var server = new DockerHelper(world);
|
||||
|
||||
server.RunCommand($"rm -rf slot-{world.ActiveSlot}");
|
||||
server.RebootServer();
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
@ -850,6 +857,11 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
||||
_context.SaveChanges();
|
||||
}
|
||||
|
||||
var server = new DockerHelper(world);
|
||||
|
||||
server.RunCommand($"sed -i 's#level-name=slot-{world.ActiveSlot}#level-name=slot-{sId}#' server.properties");
|
||||
server.RebootServer();
|
||||
|
||||
world.ActiveSlot = sId;
|
||||
world.Minigame = null;
|
||||
world.WorldType = nameof(WorldTypeEnum.NORMAL);
|
||||
|
@ -58,6 +58,18 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
|
||||
serverProcess.Start();
|
||||
}
|
||||
|
||||
public void RebootServer()
|
||||
{
|
||||
ProcessStartInfo serverProcessInfo = new();
|
||||
|
||||
serverProcessInfo.FileName = "docker";
|
||||
serverProcessInfo.Arguments = $"container restart realm-server-{world.Id}";
|
||||
|
||||
Process serverProcess = new();
|
||||
serverProcess.StartInfo = serverProcessInfo;
|
||||
serverProcess.Start();
|
||||
}
|
||||
|
||||
public void DeleteServer()
|
||||
{
|
||||
ProcessStartInfo serverProcessInfo = new();
|
||||
@ -110,5 +122,18 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
|
||||
|
||||
commandProcess.Start();
|
||||
}
|
||||
|
||||
public void RunCommand(string command)
|
||||
{
|
||||
ProcessStartInfo commandProcessInfo = new();
|
||||
|
||||
commandProcessInfo.FileName = "docker";
|
||||
commandProcessInfo.Arguments = $"exec realm-server-{world.Id} /bin/sh -c \"{command}\"";
|
||||
|
||||
Process commandProcess = new();
|
||||
commandProcess.StartInfo = commandProcessInfo;
|
||||
|
||||
commandProcess.Start();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,7 @@
|
||||
FROM eclipse-temurin:21-jre-alpine
|
||||
|
||||
WORKDIR /server
|
||||
COPY . .
|
||||
|
||||
RUN mkdir mc
|
||||
WORKDIR mc
|
||||
|
||||
RUN apk upgrade
|
||||
RUN apk add openssl
|
||||
|
||||
@ -15,19 +11,8 @@ RUN tar xzf rcon-cli.tar.gz
|
||||
RUN rm rcon-cli.tar.gz
|
||||
RUN mv rcon-cli /bin/rcon-cli
|
||||
|
||||
WORKDIR mc
|
||||
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
|
||||
|
||||
EXPOSE 25565
|
||||
|
||||
RUN java -jar server.jar
|
||||
|
||||
RUN echo "$(openssl rand -hex 20)" > .rcon-pwd
|
||||
|
||||
RUN echo eula=true > eula.txt
|
||||
RUN echo "enable-rcon=true" >> server.properties
|
||||
RUN echo "rcon.password=$(cat .rcon-pwd)" >> server.properties
|
||||
|
||||
RUN echo "password: $(cat .rcon-pwd)" >> /root/.rcon-cli.yaml
|
||||
|
||||
RUN rm .rcon-pwd
|
||||
CMD ["java", "-jar", "server.jar"]
|
||||
ENTRYPOINT ["/entrypoint"]
|
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
RCON_PASSWORD="$(openssl rand -hex 20)"
|
||||
echo "password: $RCON_PASSWORD" >> /root/.rcon-cli.yaml
|
||||
|
||||
[ ! -f eula.txt ] && echo "eula=true" > eula.txt
|
||||
|
||||
if [ ! -f server.properties ]; then
|
||||
echo "enable-rcon=true" >> server.properties
|
||||
echo "rcon.password=$RCON_PASSWORD" >> server.properties
|
||||
echo "level-name=slot-1" >> server.properties
|
||||
fi
|
||||
|
||||
java -jar server.jar
|
Loading…
x
Reference in New Issue
Block a user