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
|
2024-10-22 21:04:38 +00:00
|
|
|
error "Console pipe needs to be enabled by setting CREATE_CONSOLE_IN_PIPE to true"
|
2024-01-20 19:13:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-10-09 16:34:37 +00:00
|
|
|
if [ $# = 0 ]; then
|
2024-10-22 21:04:38 +00:00
|
|
|
error "Pass console commands as arguments"
|
2021-10-09 16:34:37 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -p "${CONSOLE_IN_NAMED_PIPE}" ]; then
|
2024-10-22 21:04:38 +00:00
|
|
|
error "Named pipe ${CONSOLE_IN_NAMED_PIPE} is missing"
|
2021-10-09 16:34:37 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-10-15 12:08:17 +00:00
|
|
|
if [ "$(id -u)" = 0 -a $UID != 0 ]; then
|
2024-10-22 21:04:38 +00:00
|
|
|
exec $(getSudoFromDistro) minecraft bash -c "echo '$*' > '${CONSOLE_IN_NAMED_PIPE}'"
|
2022-03-11 20:34:10 +00:00
|
|
|
else
|
2024-10-22 21:04:38 +00:00
|
|
|
echo "$@" >"${CONSOLE_IN_NAMED_PIPE}"
|
2022-04-19 22:42:40 +00:00
|
|
|
fi
|