check_status.sh 1.0 KB

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