Skip to content

Commit f5c95df

Browse files
authored
Add mc-send-to-console support (#228)
1 parent 29e84f2 commit f5c95df

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ RUN easy-add --var version=1.5.0 --var app=restify --file {{.app}} --from https:
3333

3434
RUN easy-add --var version=0.5.0 --var app=mc-monitor --file {{.app}} --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_linux_${ARCH}.tar.gz
3535

36-
COPY *.sh /opt/
36+
COPY scripts/* /opt/
37+
COPY bin/* /usr/local/bin/
3738

3839
COPY property-definitions.json /etc/bds-property-definitions.json
3940

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,17 @@ For more information [FoxyNoTail](https://www.youtube.com/watch?v=nWBM4UFm0rQ&t=
188188
189189
For more information about managing Bedrock Dedicated Servers in general, [check out this Reddit post](https://old.reddit.com/user/ProfessorValko/comments/9f438p/bedrock_dedicated_server_tutorial/).
190190
191-
## Executing server commands
191+
## Sending commands to the server
192+
193+
To send individual commands to the server, exec `mc-send-to-console` inside the container passing the server command as its arguments. For example, the following would disable the `falldamage` gamerule:
194+
195+
```shell
196+
docker exec $container mc-send-to-console gamerule falldamage false
197+
```
198+
199+
> NOTE: to see the output/results of the command, use `docker logs -f $container`
200+
201+
## Interactive server console
192202

193203
Assuming you started container with stdin and tty enabled (such as using `-it`), you can attach to the container's console by its name or ID using:
194204

bin/mc-send-to-console

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
: "${CONSOLE_IN_NAMED_PIPE:=/var/run/bds-stdin}"
4+
5+
if [ $# = 0 ]; then
6+
echo "ERROR: pass console commands as arguments"
7+
exit 1
8+
fi
9+
10+
if [ ! -p "${CONSOLE_IN_NAMED_PIPE}" ]; then
11+
echo "ERROR: named pipe ${CONSOLE_IN_NAMED_PIPE} is missing"
12+
exit 1
13+
fi
14+
15+
/usr/local/bin/entrypoint-demoter --match /data bash -c "echo $* > '${CONSOLE_IN_NAMED_PIPE}'"

bedrock-entry.sh renamed to scripts/bedrock-entry.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,8 @@ set-property --file server.properties --bulk /etc/bds-property-definitions.json
160160
export LD_LIBRARY_PATH=.
161161

162162
echo "Starting Bedrock server..."
163-
exec ./bedrock_server-${VERSION}
163+
164+
mkfifo /var/run/bds-stdin
165+
# See https://serverfault.com/a/1088115/196770
166+
sleep infinity > /var/run/bds-stdin &
167+
exec ./bedrock_server-"${VERSION}" < /var/run/bds-stdin

0 commit comments

Comments
 (0)