2021-10-09 16:34:37 +00:00
|
|
|
#!/bin/bash
|
2022-04-19 22:42:40 +00:00
|
|
|
. "/start-utils"
|
2021-10-09 16:34:37 +00:00
|
|
|
: "${CONSOLE_IN_NAMED_PIPE:=/tmp/minecraft-console-in}"
|
|
|
|
|
2024-01-20 19:13:26 +00:00
|
|
|
if isFalse "${CREATE_CONSOLE_IN_PIPE:-false}"; then
|
|
|
|
echo "ERROR: console pipe needs to be enabled by setting CREATE_CONSOLE_IN_PIPE to true"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-10-09 16:34:37 +00:00
|
|
|
if [ $# = 0 ]; then
|
|
|
|
echo "ERROR: pass console commands as arguments"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -p "${CONSOLE_IN_NAMED_PIPE}" ]; then
|
|
|
|
echo "ERROR: named pipe ${CONSOLE_IN_NAMED_PIPE} is missing"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-03-11 20:34:10 +00:00
|
|
|
if [ "$(id -u)" = 0 ]; then
|
2022-04-19 22:42:40 +00:00
|
|
|
if [[ $(getDistro) == alpine ]]; then
|
2023-04-23 17:44:27 +00:00
|
|
|
exec su-exec minecraft bash -c "echo '$*' > '${CONSOLE_IN_NAMED_PIPE:-/tmp/minecraft-console-in}'"
|
2022-04-19 22:42:40 +00:00
|
|
|
else
|
2023-04-23 17:44:27 +00:00
|
|
|
exec gosu minecraft bash -c "echo '$*' > '${CONSOLE_IN_NAMED_PIPE:-/tmp/minecraft-console-in}'"
|
2022-04-19 22:42:40 +00:00
|
|
|
fi
|
2022-03-11 20:34:10 +00:00
|
|
|
else
|
2022-04-19 22:42:40 +00:00
|
|
|
echo "$@" >"${CONSOLE_IN_NAMED_PIPE:-/tmp/minecraft-console-in}"
|
|
|
|
fi
|