check_status.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # LGSM check_status.sh function
  3. # Author: Daniel Gibbs
  4. # Contributor: UltimateByte
  5. # Website: https://gameservermanagers.com
  6. # Description: Checks the proccess status of the server. Either online or offline.
  7. local commandname="CHECK"
  8. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  9. if [ "${gamename}" == "Teamspeak 3" ]; then
  10. # 1: Server is running
  11. # 0: Server seems to have died
  12. # 0: No server running (ts3server.pid is missing)
  13. status=$(${executabledir}/ts3server_startscript.sh status servercfgfullpathfile=${servercfgfullpath})
  14. if [ "${status}" == "Server is running" ]; then
  15. status=1
  16. else
  17. ts3error="${status}"
  18. status=0
  19. fi
  20. elif [ "${gamename}" == "Mumble" ]; then
  21. # 1: Server is listening
  22. # 0: Server is not listening, considered closed
  23. mumblepid=$(netstat -nap 2>/dev/null | grep udp | grep 64738 | grep murmur | awk '{ print $6 }' | awk -F'/' '{ print $1 }')
  24. if [ -z "${mumblepid}" ]; then
  25. status=0
  26. else
  27. status=1
  28. fi
  29. else
  30. status=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:")
  31. fi