diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1312090 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +*.sh text eol=lf \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index d8543ff..daa3e82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,13 @@ ENV RENDER_SIGNS_JOINER "
" ENV CONFIG_LOCATION /home/minecraft/config.py +# Install rcon-cli (https://github.com/itzg/rcon-cli). Perform a checksum check +# to make sure it hasn't changed from underneath us. +ENV RCON_CLI_URL "https://github.com/itzg/rcon-cli/releases/download/1.4.7/rcon-cli_1.4.7_linux_amd64.tar.gz" +ENV RCON_CLI_SHA256 "cae03daceb3c463f0979ed0586778fb236cfbb83585413a9a06b1e83bceefa20" +ENV RCON_CLI_ARGS_PRE_RENDER "" +ENV RCON_CLI_ARGS_POST_RENDER "" + RUN apt-get update && \ apt-get install -y wget gnupg optipng && \ echo "deb http://overviewer.org/debian ./" >> /etc/apt/sources.list && \ @@ -36,6 +43,12 @@ RUN apt-get update && \ useradd -m minecraft -u 1000 -g 1000 && \ mkdir -p /home/minecraft/render /home/minecraft/server +# Install rcon-cli to support issuing RCON commands before/after the render +RUN wget "${RCON_CLI_URL}" -O "/tmp/rcon-cli.tgz" && \ + echo "${RCON_CLI_SHA256} /tmp/rcon-cli.tgz" | sha256sum -c - && \ + tar -xf /tmp/rcon-cli.tgz -C /usr/local/bin rcon-cli && \ + rm /tmp/rcon-cli.tgz + COPY config/config.py /home/minecraft/config.py COPY entrypoint.sh /home/minecraft/entrypoint.sh COPY download_url.py /home/minecraft/download_url.py diff --git a/README.md b/README.md index 312f6f8..b48056f 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ docker run \ - `CONFIG_LOCATION` Default Value: `/home/minecraft/config.py`. Set to a different path to override the provided configuration. This only makes sense if you have a different configuration in a volume. +- `RCON_CLI_ARGS_POST_RENDER` + Default Value: _null_. Set to contain any [Minecraft RCON](https://wiki.vg/RCON) command you'd like to have run after the render completes. This uses [`itzg/rcon-cli`](https://github.com/itzg/rcon-cli), so please refer to that project for full list of available options. Could be used to issue `save on` to re-enable file writes once done rendering. + +- `RCON_CLI_ARGS_PRE_RENDER` + Default Value: _null_. Set to contain any [Minecraft RCON](https://wiki.vg/RCON) command you'd like to have run before the render starts. This uses [`itzg/rcon-cli`](https://github.com/itzg/rcon-cli), so please refer to that project for full list of available options. Could be used to issue `save off` to prevent file changes while rendering. + - `RENDER_MAP` Default Value: `true`. Set to `false` if you do not want to render the map. This is useful for POI only-updates. diff --git a/entrypoint.sh b/entrypoint.sh index 87fafc4..e7038a1 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -39,6 +39,12 @@ if grep -q "texturepath" "${CONFIG_LOCATION}"; then cp "${NEW_LOCATION}" "${OLD_LOCATION}" fi +if [ -n "$RCON_CLI_ARGS_PRE_RENDER" ]; then + echo "Running rcon-cli before starting render..." + # shellcheck disable=SC2086 + rcon-cli $RCON_CLI_ARGS_PRE_RENDER +fi + # Render the Map if [ "$RENDER_MAP" == "true" ]; then overviewer.py --config "$CONFIG_LOCATION" $ADDITIONAL_ARGS @@ -48,3 +54,9 @@ fi if [ "$RENDER_POI" == "true" ]; then overviewer.py --config "$CONFIG_LOCATION" --genpoi $ADDITIONAL_ARGS_POI fi + +if [ -n "$RCON_CLI_ARGS_POST_RENDER" ]; then + echo "Running rcon-cli after finishing render..." + # shellcheck disable=SC2086 + rcon-cli $RCON_CLI_ARGS_POST_RENDER +fi