migrate to custom RCON client
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
## v0.2.0
|
||||||
|
- Migrate to custom RCON client: https://gitea.jovan04.com/evan/WiRCON
|
||||||
|
- Upgrade base image to Java 25
|
||||||
|
|
||||||
## v0.1.0
|
## v0.1.0
|
||||||
- Initial release
|
- Initial release
|
||||||
- Graceful shutdown via SIGTERM / SIGINT
|
- Graceful shutdown via SIGTERM / SIGINT
|
||||||
|
|||||||
+12
-14
@@ -1,26 +1,24 @@
|
|||||||
# extract mcrcon
|
|
||||||
FROM debian:bookworm-slim AS builder
|
|
||||||
|
|
||||||
ADD https://github.com/Tiiffi/mcrcon/releases/download/v0.7.2/mcrcon-0.7.2-linux-x86-64-static.zip /usr/bin/mcrcon.zip
|
|
||||||
RUN apt-get update && apt-get install -y unzip
|
|
||||||
|
|
||||||
RUN unzip -j /usr/bin/mcrcon.zip -d /usr/bin/mc-rcon && chmod a+x /usr/bin/mc-rcon/mcrcon
|
|
||||||
|
|
||||||
|
|
||||||
# actual image
|
# actual image
|
||||||
FROM eclipse-temurin:25
|
FROM eclipse-temurin:25
|
||||||
|
|
||||||
# included in case the base image doesn't include wget (known bug 08/2026)
|
RUN apt-get update
|
||||||
RUN apt-get update && apt-get install -y wget ca-certificates
|
RUN apt-get install -y wget ca-certificates
|
||||||
|
RUN apt-get install -y git
|
||||||
|
RUN apt-get install -y python3
|
||||||
|
RUN apt-get install -y build-essential
|
||||||
|
|
||||||
COPY --from=builder /usr/bin/mc-rcon /usr/bin/mc-rcon
|
RUN ln -s /usr/bin/python3 /usr/bin/python
|
||||||
|
|
||||||
|
# build the RCON client
|
||||||
|
RUN git clone https://gitea.jovan04.com/evan/WiRCON && cd WiRCON && make build && mv wircon.pyz /usr/bin/wircon.pyz && cp scripts/restart.py /usr/bin/restart.py
|
||||||
|
|
||||||
COPY scripts/start-server.sh /usr/bin/start-server.sh
|
COPY scripts/start-server.sh /usr/bin/start-server.sh
|
||||||
RUN chmod a+x /usr/bin/start-server.sh
|
RUN chmod a+x /usr/bin/start-server.sh
|
||||||
|
|
||||||
COPY scripts/mcrcon /usr/bin/mcrcon
|
COPY scripts/rcon /usr/bin/rcon
|
||||||
RUN chmod a+x /usr/bin/mcrcon
|
RUN chmod a+x /usr/bin/rcon
|
||||||
|
|
||||||
|
# default minecraft server files
|
||||||
COPY template/ /defaults/
|
COPY template/ /defaults/
|
||||||
|
|
||||||
WORKDIR /minecraft_data
|
WORKDIR /minecraft_data
|
||||||
|
|||||||
@@ -67,19 +67,18 @@ Log into the container:
|
|||||||
```sh
|
```sh
|
||||||
docker exec -it minecraft_server bash
|
docker exec -it minecraft_server bash
|
||||||
```
|
```
|
||||||
Use the provided wrapper script (located at `/usr/bin/mcrcon`). The script dynamically reads the password from `/minecraft_data/server.properties`.
|
Use the provided wrapper script (located at `/usr/bin/rcon`). The script dynamically reads the password from `/minecraft_data/server.properties`.
|
||||||
|
|
||||||
Send a single command:
|
Send a single command:
|
||||||
```sh
|
```sh
|
||||||
mcrcon list
|
rcon -e list
|
||||||
mcrcon stop
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For an interactive console (`Ctrl-C` or `Ctrl-D` to quit):
|
For an interactive console (`Ctrl-D` to quit):
|
||||||
```sh
|
```sh
|
||||||
mcrcon
|
rcon
|
||||||
```
|
```
|
||||||
Use this the same as typing into the actual server console
|
Use this the same as typing into the actual server console.
|
||||||
|
|
||||||
### Graceful Shutdown Behavior
|
### Graceful Shutdown Behavior
|
||||||
When the container receives SIGTERM or SIGINT:
|
When the container receives SIGTERM or SIGINT:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
exec /usr/bin/mc-rcon/mcrcon -p "$(
|
exec /usr/bin/wircon.pyz -H localhost -p "$(
|
||||||
grep '^rcon.password=' /minecraft_data/server.properties | cut -d= -f2-
|
grep '^rcon.password=' /minecraft_data/server.properties | cut -d= -f2-
|
||||||
)" "$@"
|
)" "$@"
|
||||||
@@ -24,12 +24,13 @@ if ! test -f /minecraft_data/eula.txt; then
|
|||||||
cp /defaults/eula.txt /minecraft_data/eula.txt
|
cp /defaults/eula.txt /minecraft_data/eula.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
export MCRCON_PASS=$(grep "^rcon.password=" /minecraft_data/server.properties | cut -d '=' -f 2- | head -n 1)
|
export MCRCON_PASS=$(grep "^rcon.password=" /minecraft_data/server.properties | cut -d '=' -f 2- | head -n 1)
|
||||||
|
|
||||||
# shutdown process
|
# shutdown process
|
||||||
function shutdown {
|
function shutdown {
|
||||||
echo "stopping Minecraft server..."
|
echo "stopping Minecraft server..."
|
||||||
/usr/bin/mc-rcon/mcrcon -p ${MCRCON_PASS} -w 5 "say Server is restarting!" save-all stop
|
/usr/bin/wircon.pyz -H localhost -p ${MCRCON_PASS} -E /usr/bin/restart.py
|
||||||
wait $SERVER_PID
|
wait $SERVER_PID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user