Upgpkg: 1.9-6

On server stop, return to the prompt as soon as the server has
completely shut down, not as soon as the shutdown command has been sent.
Thereby fixing the restart capability.
Introduce sanity check whether the servers is really down in idle_daemon
and server_start as well.

Signed-off-by: Gordian Edenhofer <gordian.edenhofer@gmail.com>
This commit is contained in:
Gordian Edenhofer 2016-03-06 13:50:10 +01:00
parent 904e9c8273
commit 8cba936144
3 changed files with 28 additions and 12 deletions

View File

@ -1,7 +1,7 @@
pkgbase = minecraft-server pkgbase = minecraft-server
pkgdesc = Minecraft server unit files, script, and jar pkgdesc = Minecraft server unit files, script, and jar
pkgver = 1.9 pkgver = 1.9
pkgrel = 5 pkgrel = 6
url = http://minecraft.net/ url = http://minecraft.net/
install = minecraft-server.install install = minecraft-server.install
arch = any arch = any
@ -28,6 +28,6 @@ pkgbase = minecraft-server
md5sums = fef6fadd0739ae03ff71ba61025be207 md5sums = fef6fadd0739ae03ff71ba61025be207
md5sums = afb84ad0316af0aca421b36eaa2bbd90 md5sums = afb84ad0316af0aca421b36eaa2bbd90
md5sums = 54438e0c47cc5083e0a4376688b46092 md5sums = 54438e0c47cc5083e0a4376688b46092
md5sums = e2fae644262285b633db924b0a384613 md5sums = 98fe0fdfe4021a522739e3e14601ad9f
pkgname = minecraft-server pkgname = minecraft-server

View File

@ -4,7 +4,7 @@
pkgname=minecraft-server pkgname=minecraft-server
pkgver=1.9 pkgver=1.9
pkgrel=5 pkgrel=6
pkgdesc="Minecraft server unit files, script, and jar" pkgdesc="Minecraft server unit files, script, and jar"
arch=('any') arch=('any')
url="http://minecraft.net/" url="http://minecraft.net/"
@ -28,7 +28,7 @@ md5sums=('ff68834eee875bcf367422c67673207c'
'fef6fadd0739ae03ff71ba61025be207' 'fef6fadd0739ae03ff71ba61025be207'
'afb84ad0316af0aca421b36eaa2bbd90' 'afb84ad0316af0aca421b36eaa2bbd90'
'54438e0c47cc5083e0a4376688b46092' '54438e0c47cc5083e0a4376688b46092'
'e2fae644262285b633db924b0a384613') '98fe0fdfe4021a522739e3e14601ad9f')
_game="minecraft" _game="minecraft"
_server_root="/srv/minecraft" _server_root="/srv/minecraft"

View File

@ -92,15 +92,20 @@ idle_server_daemon() {
# Stop the game server if no player was active for at least ${IDLE_IF_TIME} # Stop the game server if no player was active for at least ${IDLE_IF_TIME}
if [[ "${no_player}" -ge "${IDLE_IF_TIME}" ]]; then if [[ "${no_player}" -ge "${IDLE_IF_TIME}" ]]; then
IDLE_SERVER="false" ${myname} stop IDLE_SERVER="false" ${myname} stop
# Wait for game server to go down
# Game server is down, listen on port ${GAME_PORT} for incoming connections for i in {1..90}; do
sleep 1 screen -S "${SESSION_NAME}" -Q select . > /dev/null
[[ $? -eq 1 ]] && break
[[ $i -eq 90 ]] && echo -e "\e[39;1m An error occured while trying to reset the idle_server! \e[0m"
sleep 0.1
done
# Listen on port ${GAME_PORT} for incoming connections
echo "Netcat is listening on port ${GAME_PORT} for incoming connections..." echo "Netcat is listening on port ${GAME_PORT} for incoming connections..."
${NETCAT_CMD} -v -l -p ${GAME_PORT} ${NETCAT_CMD} -v -l -p ${GAME_PORT}
[[ $? -eq 0 ]] && echo "Netcat caught an connection. The server is coming up again...." [[ $? -eq 0 ]] && echo "Netcat caught an connection. The server is coming up again...."
IDLE_SERVER="false" ${myname} start IDLE_SERVER="false" ${myname} start
fi fi
else elif [[ $? -eq 0 ]]; then
no_player=0 no_player=0
fi fi
else else
@ -136,8 +141,13 @@ server_start() {
${SUDO_CMD} screen -S "${IDLE_SESSION_NAME}" -Q select . > /dev/null ${SUDO_CMD} screen -S "${IDLE_SESSION_NAME}" -Q select . > /dev/null
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
${SUDO_CMD} screen -S "${IDLE_SESSION_NAME}" -X quit ${SUDO_CMD} screen -S "${IDLE_SESSION_NAME}" -X quit
sleep 0.5 # Restart as soon as the idle_server_daemon has shut down completely
${SUDO_CMD} screen -dmS "${IDLE_SESSION_NAME}" /bin/bash -c "${myname} idle_server_daemon" for i in {1..30}; do
${SUDO_CMD} screen -S "${IDLE_SESSION_NAME}" -Q select . > /dev/null
[[ $? -eq 1 ]] && ${SUDO_CMD} screen -dmS "${IDLE_SESSION_NAME}" /bin/bash -c "${myname} idle_server_daemon" && break
[[ $i -eq 30 ]] && echo -e "\e[39;1m An error occured while trying to reset the idle_server! \e[0m"
sleep 0.1
done
else else
echo -en "Starting idle server daeomon... " echo -en "Starting idle server daeomon... "
${SUDO_CMD} screen -dmS "${IDLE_SESSION_NAME}" /bin/bash -c "${myname} idle_server_daemon" ${SUDO_CMD} screen -dmS "${IDLE_SESSION_NAME}" /bin/bash -c "${myname} idle_server_daemon"
@ -178,7 +188,14 @@ server_stop() {
sleep 1 sleep 1
done done
game_command stop game_command stop
echo -e "\e[39;1m done\e[0m"
# Finish as soon as the server has shut down completely
for i in {1..30}; do
${SUDO_CMD} screen -S "${SESSION_NAME}" -Q select . > /dev/null
[[ $? -eq 1 ]] && echo -e "\e[39;1m done\e[0m" && break
[[ $i -eq 30 ]] && echo -e "\e[39;1m ERROR\e[0m"
sleep 0.1
done
else else
echo "The corresponding screen session for ${SESSION_NAME} was already dead." echo "The corresponding screen session for ${SESSION_NAME} was already dead."
fi fi
@ -221,7 +238,6 @@ server_restart() {
${SUDO_CMD} screen -S "${SESSION_NAME}" -Q select . > /dev/null ${SUDO_CMD} screen -S "${SESSION_NAME}" -Q select . > /dev/null
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
server_stop server_stop
sleep 0.5
server_start server_start
else else
server_start server_start