check_status.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. # LinuxGSM check_status.sh function
  3. # Author: Daniel Gibbs
  4. # Contributor: UltimateByte
  5. # Website: https://linuxgsm.com
  6. # Description: Checks the process 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. # Get config info
  22. info_config.sh
  23. # 1: Server is listening
  24. # 0: Server is not listening, considered closed
  25. mumblepid=$(netstat -nap 2>/dev/null | grep udp | grep "${port}" | grep murmur | awk '{ print $6 }' | awk -F'/' '{ print $1 }')
  26. if [ -z "${mumblepid}" ]; then
  27. status=0
  28. else
  29. status=1
  30. fi
  31. else
  32. status=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:")
  33. fi