aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorGordian Edenhofer2021-10-20 22:15:40 +0200
committerGordian Edenhofer2021-10-20 22:27:13 +0200
commitc101fe52b03078a9d0d0ee700fadd966a62c267a (patch)
treef0fe1595b0301190cb7afa0cf8a3b483262f6ea3
parente111682c03208fedb703c0fc153011329538beb5 (diff)
downloadaur-c101fe52b03078a9d0d0ee700fadd966a62c267a.tar.gz
upgpkg: minecraft-server 1.17.1-3
Print the output of the server to the terminal if startup fails. Evaluate a failure during startup by constantly inspecting the output of the server for the first 15 seconds during startup. Relates to #13 . upgpkg: cuberite 1.12.2c1_afe07fe-1 upgpkg: cuberite-bin 1.12.2b284-3 upgpkg: papermc 1.17.1+b341-1 upgpkg: spigot 1.17.1+b131-4
-rw-r--r--.SRCINFO22
-rw-r--r--PKGBUILD6
-rwxr-xr-xcuberite.sh56
3 files changed, 62 insertions, 22 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 062c5725cbfe..f191abd0e1e8 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = cuberite-bin
pkgdesc = A Minecraft-compatible multiplayer game server that is written in C++ and designed to be efficient with memory and CPU, as well as having a flexible Lua Plugin API. It is compatible with the vanilla Minecraft client.
- pkgver = 1.12.2b258
+ pkgver = 1.12.2b284
pkgrel = 3
url = https://cuberite.org/
install = cuberite.install
@@ -20,9 +20,9 @@ pkgbase = cuberite-bin
provides = spigot=1.12.2
provides = cuberite=1.12.2
conflicts = cuberite
- noextract = Cuberite.b268_i686.tar.gz
- noextract = Cuberite.b258_x86_64.tar.gz
- noextract = Cuberite.b258_armv7h.tar.gz
+ noextract = Cuberite.b294_i686.tar.gz
+ noextract = Cuberite.b284_x86_64.tar.gz
+ noextract = Cuberite.b290_armv7h.tar.gz
backup = etc/conf.d/cuberite
source = cuberite-backup.service
source = cuberite-backup.timer
@@ -37,12 +37,12 @@ pkgbase = cuberite-bin
sha512sums = 0e82acfe3e907f3976e96aebb146d12f076a26e4478f3330d4f0ded44956624094abc35e56402f6a994fb5852fbc7e901e4e2b8f1ae31f3e82224e6bc15eba0b
sha512sums = 09047f4df9591b2d61885c842cbd9abde590b0069945f2e10fd402ad93f0f0abd3c2557e61200388038708960f5d82e22d332efe83cf1acf0895f56dd2e5d5d0
sha512sums = 9282301a67a612a4b757324274b6deea16d57e919b3c367a92414d7b74fe0ec4f5e54748ccf0ff14f6c62e8dbc5cb211afebfff8ad5abe63945afccf9484378f
- sha512sums = 31260a205a72833679e164e5c4d8513ec244051032e1527874dda66629def39519a6f23e1e6b12cdeff75423f812502474893e518535e77d8ec486e834f9ad13
- source_i686 = Cuberite.b268_i686.tar.gz::https://builds.cuberite.org/view/all/job/linux-i386/268/artifact/Cuberite.tar.gz
- sha512sums_i686 = 12a94ca2f55be3fbc147b1ddee2782c99bdc20619050cb15196e6b802691cb9e8003258e1fbc6a582dae731c40a823a19519e2ea29056c34f4f041905bc4129b
- source_x86_64 = Cuberite.b258_x86_64.tar.gz::https://builds.cuberite.org/view/all/job/linux-x86_64/258/artifact/Cuberite.tar.gz
- sha512sums_x86_64 = ad6a944ee505caa2b3e9e01f3dec8635bd49eabedc36702c86b331d08638af24117b978b80af7ddbc087e3495363d3cf0354057d21148636e485b26f0603d7bd
- source_armv7h = Cuberite.b258_armv7h.tar.gz::https://builds.cuberite.org/view/all/job/linux-armhf/258/artifact/Cuberite.tar.gz
- sha512sums_armv7h = 9ed1c27426ca734688517fd025a41a256a7fadfbb7023dfaf71d7c89e362840010673dc9955d9c682c61d203a5118c0012c3c7fd662e24ef11410e0d26ab1549
+ sha512sums = efd901f673e36c9bc0e63fe7ccadcb5ce8fa112f65a0fb7c2ed46cd66840edffb01731e18f22f1f760463474e35a6e7223e0cdf2ef6ba5dedaea6d351ad98f1f
+ source_i686 = Cuberite.b294_i686.tar.gz::https://builds.cuberite.org/view/all/job/linux-i386/294/artifact/Cuberite.tar.gz
+ sha512sums_i686 = a338e9219db3800b76c2ef7f29f1dd95f28e00e2ca67c872c5d839ef34377da43697672925b8f0feaed85f833bd5c143ee5a270ffb7da0b6b13a2d42a269c75d
+ source_x86_64 = Cuberite.b284_x86_64.tar.gz::https://builds.cuberite.org/view/all/job/linux-x86_64/284/artifact/Cuberite.tar.gz
+ sha512sums_x86_64 = abcf2c6455cb3293f3d26ba9fff4297cb4c40aa4192290139a15f7fa34cb82bdd091d6771f627888829e6c5e80c51fbb60ecf0cf04d27f960fd9b8e1ce4f9b33
+ source_armv7h = Cuberite.b290_armv7h.tar.gz::https://builds.cuberite.org/view/all/job/linux-armhf/290/artifact/Cuberite.tar.gz
+ sha512sums_armv7h = c194bc7d60ac05c7919cccae59840c884ee2572a8bfed52889772cb09e21a7f35dc7f052eb81a3a56e4cf217bdcb5e5747be6069190e30f5fec65d5fd3958dd8
pkgname = cuberite-bin
diff --git a/PKGBUILD b/PKGBUILD
index 0b6cf8889f67..e85fc4a1a256 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,9 +3,9 @@
_pkgname=cuberite
pkgname=cuberite-bin
_pkgver=1.12.2
-_build_i686=268
-_build_x86_64=258
-_build_armv7h=258
+_build_i686=294
+_build_x86_64=284
+_build_armv7h=290
pkgver="${_pkgver}b${_build_x86_64}"
pkgrel=3
pkgdesc="A Minecraft-compatible multiplayer game server that is written in C++ and designed to be efficient with memory and CPU, as well as having a flexible Lua Plugin API. It is compatible with the vanilla Minecraft client."
diff --git a/cuberite.sh b/cuberite.sh
index 804a0876cb67..b1727d79164f 100755
--- a/cuberite.sh
+++ b/cuberite.sh
@@ -20,6 +20,7 @@ declare -r game="cuberite"
# Command and parameter declaration with which to start the server
[[ -n "${SERVER_START_CMD}" ]] && declare -r SERVER_START_CMD=${SERVER_START_CMD} || SERVER_START_CMD="./${MAIN_EXECUTABLE}"
+[[ -n "${SERVER_START_SUCCESS}" ]] && declare -r SERVER_START_SUCCESS=${SERVER_START_SUCCESS} || SERVER_START_SUCCESS="complete"
# System parameters for the control script
[[ -n "${IDLE_SERVER}" ]] && tmp_IDLE_SERVER=${IDLE_SERVER} || IDLE_SERVER="false"
@@ -43,6 +44,8 @@ set -u
# Exit if a single command breaks and its failure is not handled accordingly
set -e
+MAX_SERVER_START_TIME=150
+
# Check whether sudo is needed at all
if [[ "$(whoami)" == "${GAME_USER}" ]]; then
SUDO_CMD=""
@@ -169,12 +172,38 @@ server_start() {
else
echo -en "Starting server..."
${SUDO_CMD} rm -f "${GAME_COMMAND_DUMP}"
+ # Use a plain file as command buffers for the server startup and switch to a FIFO pipe later
+ ${SUDO_CMD} touch "${GAME_COMMAND_DUMP}"
+ # Ensure pipe-pine is started before the server itself by splitting the session creation and server startup
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" new-session -s "${SESSION_NAME}" -c "${SERVER_ROOT}" -d /bin/bash
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" wait-for -L "command_lock"
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" pipe-pane -t "${SESSION_NAME}":0.0 "cat > ${GAME_COMMAND_DUMP}"
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" send-keys -t "${SESSION_NAME}":0.0 "exec ${SERVER_START_CMD}" Enter
+ for ((i=1; i<=MAX_SERVER_START_TIME; i++)); do
+ sleep "${sleep_time:-0.1}"
+ if ! socket_session_is_alive "${SESSION_NAME}"; then
+ echo -e "\e[39;1m failed\e[0m\n"
+ >&2 ${SUDO_CMD} cat "${GAME_COMMAND_DUMP}"
+ ${SUDO_CMD} rm -f "${GAME_COMMAND_DUMP}"
+ # Session is dead but remain-on-exit left it open; close it for sure
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" kill-session -t "${SESSION_NAME}"
+ exit 1
+ elif grep -q -i "${SERVER_START_SUCCESS}" "${GAME_COMMAND_DUMP}"; then
+ echo -e "\e[39;1m done\e[0m"
+ break
+ elif [[ $i -eq ${MAX_SERVER_START_TIME} ]]; then
+ echo -e "\e[39;1m skipping\e[0m"
+ >&2 echo -e "Server startup has not finished yet; continuing anyways"
+ fi
+ done
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" pipe-pane -t "${SESSION_NAME}":0.0
+ # Let the command buffer be a FIFO pipe
+ ${SUDO_CMD} rm -f "${GAME_COMMAND_DUMP}"
${SUDO_CMD} mkfifo "${GAME_COMMAND_DUMP}"
- ${SUDO_CMD} tmux -L "${SESSION_NAME}" new-session -s "${SESSION_NAME}" -c "${SERVER_ROOT}" -d "${SERVER_START_CMD}"
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" wait-for -U "command_lock"
# Mimic GNU screen and allow for both C-a and C-b as prefix
${SUDO_CMD} tmux -L "${SESSION_NAME}" set -g prefix2 C-a
- echo -e "\e[39;1m done\e[0m"
fi
if [[ "${IDLE_SERVER,,}" == "true" ]]; then
@@ -189,12 +218,12 @@ server_start() {
${SUDO_CMD} tmux -L "${SESSION_NAME}" kill-session -t "${IDLE_SESSION_NAME}"
# Restart as soon as the idle_server_daemon has shut down completely
for i in {1..100}; do
+ sleep 0.1
if ! socket_has_session "${IDLE_SESSION_NAME}"; then
${SUDO_CMD} tmux -L "${SESSION_NAME}" new-session -s "${IDLE_SESSION_NAME}" -d "${myname} idle_server_daemon"
break
fi
[[ $i -eq 100 ]] && echo -e "An \e[39;1merror\e[0m occurred while trying to reset the idle_server!"
- sleep 0.1
done
else
echo -en "Starting idle server daemon..."
@@ -216,7 +245,7 @@ server_stop() {
if socket_has_session "${IDLE_SESSION_NAME}"; then
echo -en "Stopping idle server daemon..."
- ${SUDO_CMD} tmux -L "${SESSION_NAME}" kill-session -t "${IDLE_SESSION_NAME}":0.0
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" kill-session -t "${IDLE_SESSION_NAME}"
echo -e "\e[39;1m done\e[0m"
else
echo "The corresponding tmux session for ${IDLE_SESSION_NAME} was already dead."
@@ -285,7 +314,7 @@ server_status() {
# Calculating memory usage
for p in $(${SUDO_CMD} pgrep -f "${MAIN_EXECUTABLE}"); do
ps -p"${p}" -O rss | tail -n 1;
- done | gawk '{ count ++; sum += $2 }; END {count --; print "Number of processes =", count, "(tmux,", count-1, "x server)"; print "Total memory usage =", sum/1024, "MB" ;};'
+ done | gawk '{ count ++; sum += $2 }; END {count --; print "Number of processes =", count, "(tmux +", count, "x server)"; print "Total memory usage =", sum/1024, "MB" ;};'
else
echo -e "Status:\e[39;1m stopped\e[0m"
fi
@@ -429,13 +458,24 @@ server_console() {
# Check if there is a session available
socket_has_session() {
if [[ "$(whoami)" != "${GAME_USER}" ]]; then
- ${SUDO_CMD} tmux -L "${SESSION_NAME}" has-session -t "${1}":0.0 2> /dev/null
- return $?
+ ${SUDO_CMD} tmux -L "${SESSION_NAME}" has-session -t "${1}":0.0 2> /dev/null
+ return $?
fi
tmux -L "${SESSION_NAME}" has-session -t "${1}":0.0 2> /dev/null
return $?
}
+socket_session_is_alive() {
+ if socket_has_session "${1}"; then
+ if [[ "$(whoami)" != "${GAME_USER}" ]]; then
+ return $(${SUDO_CMD} tmux -L "${SESSION_NAME}" list-panes -t "${1}":0.0 -F '#{pane_dead}' 2> /dev/null)
+ fi
+ return $(tmux -L "${SESSION_NAME}" list-panes -t "${1}":0.0 -F '#{pane_dead}' 2> /dev/null)
+ else
+ return 1
+ fi
+}
+
# Help function, no arguments required
help() {
cat <<-EOF
@@ -490,7 +530,7 @@ case "${1:-}" in
;;
idle_server_daemon)
- # This shall be a hidden function which should only be invoced internally
+ # This shall be a hidden function which should only be invoked internally
idle_server_daemon
;;