mirror of
https://github.com/CyberL1/Minecraft-Realms-Emulator.git
synced 2025-04-04 06:58:37 -04:00
Compare commits
3 Commits
28e678bce9
...
b6a73df815
Author | SHA1 | Date | |
---|---|---|---|
b6a73df815 | |||
cbecb21ea3 | |||
1a3804e865 |
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Resources\files\template\Dockerfile" />
|
<EmbeddedResource Include="Resources\files\template\Dockerfile" />
|
||||||
|
<EmbeddedResource Include="Resources\files\template\entrypoint" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -657,6 +657,13 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
|||||||
public ActionResult<bool> Reset(int wId)
|
public ActionResult<bool> Reset(int wId)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Resetting world {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);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -850,6 +857,11 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Controllers
|
|||||||
_context.SaveChanges();
|
_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.ActiveSlot = sId;
|
||||||
world.Minigame = null;
|
world.Minigame = null;
|
||||||
world.WorldType = nameof(WorldTypeEnum.NORMAL);
|
world.WorldType = nameof(WorldTypeEnum.NORMAL);
|
||||||
|
@ -58,6 +58,18 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
|
|||||||
serverProcess.Start();
|
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()
|
public void DeleteServer()
|
||||||
{
|
{
|
||||||
ProcessStartInfo serverProcessInfo = new();
|
ProcessStartInfo serverProcessInfo = new();
|
||||||
@ -110,5 +122,18 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
|
|||||||
|
|
||||||
commandProcess.Start();
|
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
|
FROM eclipse-temurin:21-jre-alpine
|
||||||
|
|
||||||
WORKDIR /server
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN mkdir mc
|
|
||||||
WORKDIR mc
|
|
||||||
|
|
||||||
RUN apk upgrade
|
RUN apk upgrade
|
||||||
RUN apk add openssl
|
RUN apk add openssl
|
||||||
|
|
||||||
@ -15,19 +11,8 @@ RUN tar xzf rcon-cli.tar.gz
|
|||||||
RUN rm rcon-cli.tar.gz
|
RUN rm rcon-cli.tar.gz
|
||||||
RUN mv rcon-cli /bin/rcon-cli
|
RUN mv rcon-cli /bin/rcon-cli
|
||||||
|
|
||||||
|
WORKDIR mc
|
||||||
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
|
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
|
||||||
|
|
||||||
EXPOSE 25565
|
EXPOSE 25565
|
||||||
|
ENTRYPOINT ["/entrypoint"]
|
||||||
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"]
|
|
@ -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