feat: rcon

This commit is contained in:
CyberL1 2024-07-05 22:05:08 +02:00
parent 07ae7c6777
commit 7bc0169dda
2 changed files with 33 additions and 2 deletions

View File

@ -80,5 +80,18 @@ namespace Minecraft_Realms_Emulator.Modes.Realms.Helpers
} }
}); });
} }
public void ExecuteCommand(string command)
{
ProcessStartInfo commandProcessInfo = new();
commandProcessInfo.FileName = "docker";
commandProcessInfo.Arguments = $"exec realm-server-{world.Id} rcon-cli {command}";
Process commandProcess = new();
commandProcess.StartInfo = commandProcessInfo;
commandProcess.Start();
}
} }
} }

View File

@ -1,4 +1,4 @@
FROM eclipse-temurin:21 FROM eclipse-temurin:21-jre-alpine
WORKDIR /server WORKDIR /server
COPY . . COPY . .
@ -6,10 +6,28 @@ COPY . .
RUN mkdir mc RUN mkdir mc
WORKDIR mc WORKDIR mc
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/145ff0858209bcfc164859ba735d4199aafa1eea/server.jar RUN apk upgrade
RUN apk add openssl
RUN wget -O rcon-cli.tar.gz https://github.com/itzg/rcon-cli/releases/download/1.6.7/rcon-cli_1.6.7_linux_amd64.tar.gz
RUN tar xzf rcon-cli.tar.gz
RUN rm rcon-cli.tar.gz
RUN mv rcon-cli /bin/rcon-cli
RUN wget -O server.jar https://piston-data.mojang.com/v1/objects/450698d1863ab5180c25d7c804ef0fe6369dd1ba/server.jar
EXPOSE 25565 EXPOSE 25565
RUN java -jar server.jar RUN java -jar server.jar
RUN echo "$(openssl rand -hex 20)" > .rcon-pwd
RUN echo eula=true > eula.txt 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"] CMD ["java", "-jar", "server.jar"]