Upgpkg: 1.9.2-2

The list command prints a line containing the usernames after the last
occurrence of ": " and since playernames may not contain this string the
clean player-list can be easily retrieved through the use of sed. This
surpasses the usefulness of the player_delimiter.
Increase waiting period between executing the list game-command and
scanning the logs from 0.3 seconds to 0.6 seconds.
Tweak tail -f command in server_command.
Use ${_game} variable aggressively in PKGBUILD.
This commit is contained in:
Gordian Edenhofer 2016-04-03 12:54:13 +02:00
parent bba22bf616
commit 349829f1e1
3 changed files with 21 additions and 23 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.2 pkgver = 1.9.2
pkgrel = 1 pkgrel = 2
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 = 00045683c06924d765ac14887218ffcc md5sums = 00045683c06924d765ac14887218ffcc
md5sums = 48cb57c426c7725483cd0c9af24048df md5sums = f130c76d285297071c3e0d2988631dfe
pkgname = minecraft-server pkgname = minecraft-server

View File

@ -4,7 +4,7 @@
pkgname=minecraft-server pkgname=minecraft-server
pkgver=1.9.2 pkgver=1.9.2
pkgrel=1 pkgrel=2
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/"
@ -13,9 +13,9 @@ depends=('java-runtime-headless' 'screen' 'sudo' 'bash')
optdepends=("tar: needed in order to create world backups" optdepends=("tar: needed in order to create world backups"
"netcat: required in order to suspend an idle server") "netcat: required in order to suspend an idle server")
conflicts=('minecraft-server-systemd' 'minecraft-canary') conflicts=('minecraft-server-systemd' 'minecraft-canary')
options=(!strip)
install=${pkgname}.install
backup=('etc/conf.d/minecraft') backup=('etc/conf.d/minecraft')
options=(!strip)
install="${pkgname}.install"
source=("https://s3.amazonaws.com/Minecraft.Download/versions/${pkgver}/minecraft_server.${pkgver}.jar" source=("https://s3.amazonaws.com/Minecraft.Download/versions/${pkgver}/minecraft_server.${pkgver}.jar"
"minecraftd-backup.service" "minecraftd-backup.service"
"minecraftd-backup.timer" "minecraftd-backup.timer"
@ -28,19 +28,19 @@ md5sums=('560d467028f17a70997151ed0053deb6'
'fef6fadd0739ae03ff71ba61025be207' 'fef6fadd0739ae03ff71ba61025be207'
'afb84ad0316af0aca421b36eaa2bbd90' 'afb84ad0316af0aca421b36eaa2bbd90'
'00045683c06924d765ac14887218ffcc' '00045683c06924d765ac14887218ffcc'
'48cb57c426c7725483cd0c9af24048df') 'f130c76d285297071c3e0d2988631dfe')
_game="minecraft" _game="minecraft"
_server_root="/srv/minecraft" _server_root="/srv/minecraft"
package() { package() {
install -Dm644 minecraftd.conf "${pkgdir}/etc/conf.d/${_game}" install -Dm644 ${_game}d.conf "${pkgdir}/etc/conf.d/${_game}"
install -Dm755 minecraftd.sh "${pkgdir}/usr/bin/${_game}d" install -Dm755 ${_game}d.sh "${pkgdir}/usr/bin/${_game}d"
install -Dm644 minecraftd.service "${pkgdir}/usr/lib/systemd/system/${_game}d.service" install -Dm644 ${_game}d.service "${pkgdir}/usr/lib/systemd/system/${_game}d.service"
install -Dm644 minecraftd-backup.service "${pkgdir}/usr/lib/systemd/system/${_game}d-backup.service" install -Dm644 ${_game}d-backup.service "${pkgdir}/usr/lib/systemd/system/${_game}d-backup.service"
install -Dm644 minecraftd-backup.timer "${pkgdir}/usr/lib/systemd/system/${_game}d-backup.timer" install -Dm644 ${_game}d-backup.timer "${pkgdir}/usr/lib/systemd/system/${_game}d-backup.timer"
install -Dm644 minecraft_server.${pkgver}.jar "${pkgdir}${_server_root}/minecraft_server.${pkgver}.jar" install -Dm644 ${_game}_server.${pkgver}.jar "${pkgdir}${_server_root}/${_game}_server.${pkgver}.jar"
ln -s "minecraft_server.${pkgver}.jar" "${pkgdir}${_server_root}/minecraft_server.jar" ln -s "${_game}_server.${pkgver}.jar" "${pkgdir}${_server_root}/${_game}_server.jar"
# Link the log files # Link the log files
mkdir -p "${pkgdir}/var/log/" mkdir -p "${pkgdir}/var/log/"

View File

@ -37,11 +37,6 @@ source /etc/conf.d/${game} || echo "Could not source /etc/conf.d/${game}"
# Preserve the content of IDLE_SERVER without making it readonly # Preserve the content of IDLE_SERVER without making it readonly
[[ ! -z ${tmp_IDLE_SERVER} ]] && IDLE_SERVER=${tmp_IDLE_SERVER} [[ ! -z ${tmp_IDLE_SERVER} ]] && IDLE_SERVER=${tmp_IDLE_SERVER}
# The variable defines the row in which the first player is printed. It is interpreted
# by awk and depends on the flavor of the game server.
# The stock minecraft server prints the first player in the 4th row, spigot in the 6th.
player_delimiter=4
# Check whether sudo is needed at all # Check whether sudo is needed at all
if [[ $(whoami) == ${GAME_USER} ]]; then if [[ $(whoami) == ${GAME_USER} ]]; then
@ -90,7 +85,9 @@ idle_server_daemon() {
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
# Game server is up and running # Game server is up and running
screen -S "${SESSION_NAME}" -X stuff "`printf \"list\r\"`" screen -S "${SESSION_NAME}" -X stuff "`printf \"list\r\"`"
if [[ $? -eq 0 && -z $(sleep 0.3; tail -n 1 "${LOGPATH}/latest.log" | awk "{ print \$${player_delimiter} }") ]]; then # The list command prints a line containing the usernames after the last occurrence of ": "
# and since playernames may not contain this string the clean player-list can be easily retrieved.
if [[ $? -eq 0 && -z $(sleep 0.6; tail -n 1 "${LOGPATH}/latest.log" | sed 's/.*\: //' | tr -d '\n') ]]; then
# No player was seen on the server through list # No player was seen on the server through list
no_player=$((no_player + CHECK_PLAYER_TIME)) no_player=$((no_player + CHECK_PLAYER_TIME))
# 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}
@ -188,7 +185,9 @@ server_stop() {
# Gracefully stop the server when there are still active players # Gracefully stop the server when there are still active players
${SUDO_CMD} screen -S "${SESSION_NAME}" -X stuff "`printf \"list\r\"`" ${SUDO_CMD} screen -S "${SESSION_NAME}" -X stuff "`printf \"list\r\"`"
if [[ $? -eq 0 && -z $(sleep 0.3; tail -n 1 "${LOGPATH}/latest.log" | awk "{ print \$${player_delimiter} }") ]]; then # The list command prints a line containing the usernames after the last occurrence of ": "
# and since playernames may not contain this string the clean player-list can be easily retrieved.
if [[ $? -eq 0 && -z $(sleep 0.6; tail -n 1 "${LOGPATH}/latest.log" | sed 's/.*\: //' | tr -d '\n') ]]; then
# No player was seen on the server through list # No player was seen on the server through list
echo -en "Server is going down..." echo -en "Server is going down..."
game_command stop game_command stop
@ -374,10 +373,9 @@ server_command() {
${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
sleep 0.3 & ${SUDO_CMD} sleep 0.3 & tail -f --pid=$! -n 0 "${LOGPATH}/latest.log" &
sleep_pid=$!
game_command "$@" game_command "$@"
${SUDO_CMD} tail -f --pid=${sleep_pid} -n 0 "${LOGPATH}/latest.log" wait
else else
echo "There is no ${SESSION_NAME} session to connect to." echo "There is no ${SESSION_NAME} session to connect to."
fi fi