check_status.sh 762 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. # LGSM check_status 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 commandnane="CHECK"
  7. local commandaction="Checking"
  8. local 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. else
  21. status=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:")
  22. fi