diff options
author | Gordian Edenhofer | 2016-04-03 16:33:16 +0200 |
---|---|---|
committer | Gordian Edenhofer | 2016-04-03 16:33:16 +0200 |
commit | 0a4c078d7548b022203bbd9d3f24c8f1f05e0387 (patch) | |
tree | 7ccd2d9b26bcdf803068a4871360a1104fbc4688 /minecraftd.sh | |
parent | 87f0b53c40ffe6968121cb5e6789b397a3e406fb (diff) | |
download | aur-0a4c078d7548b022203bbd9d3f24c8f1f05e0387.tar.gz |
Upgpkg: 1.9.2-3
Escape colored game-command output when evaluating the logs. Though this
is not the default for the stock server, some plugins add color to e.g.
list.
Set tail -f refresh interval to 0.1s (default 1s) to speedily escape.
Diffstat (limited to 'minecraftd.sh')
-rwxr-xr-x | minecraftd.sh | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/minecraftd.sh b/minecraftd.sh index 4ef6997592b0..a53bcdea5721 100755 --- a/minecraftd.sh +++ b/minecraftd.sh @@ -87,7 +87,7 @@ idle_server_daemon() { screen -S "${SESSION_NAME}" -X stuff "`printf \"list\r\"`" # 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 + if [[ $? -eq 0 && -z $(sleep 0.6; tail -n 1 "${LOGPATH}/latest.log" | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | sed 's/.*\: //' | tr -d '\n') ]]; then # No player was seen on the server through list no_player=$((no_player + CHECK_PLAYER_TIME)) # Stop the game server if no player was active for at least ${IDLE_IF_TIME} @@ -184,7 +184,7 @@ server_stop() { ${SUDO_CMD} screen -S "${SESSION_NAME}" -X stuff "`printf \"list\r\"`" # 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 + if [[ $? -eq 0 && -z $(sleep 0.6; tail -n 1 "${LOGPATH}/latest.log" | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | sed 's/.*\: //' | tr -d '\n') ]]; then # No player was seen on the server through list echo -en "Server is going down..." game_command stop @@ -239,7 +239,7 @@ server_status() { # Calculating memory usage for p in $(${SUDO_CMD} pgrep -f "${MAIN_EXECUTABLE}"); do - ps -p${p} -O rss | tail -n1; + ps -p${p} -O rss | tail -n 1; done | gawk '{ count ++; sum += $2 }; END {count --; print "Number of processes =", count, "(screen, bash,", count-2, "x java)"; print "Total memory usage =", sum/1024, "MB" ;};' else echo -e "Status:\e[39;1m stopped\e[0m" @@ -371,7 +371,7 @@ server_command() { ${SUDO_CMD} screen -S "${SESSION_NAME}" -Q select . > /dev/null if [[ $? -eq 0 ]]; then - ${SUDO_CMD} sleep 0.3 & tail -f --pid=$! -n 0 "${LOGPATH}/latest.log" & + ${SUDO_CMD} sleep 0.3 & tail -f --pid=$! -s 0.1 -n 0 "${LOGPATH}/latest.log" & game_command "$@" wait else |