check_status.sh 742 B

1234567891011121314151617181920212223
  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 modulename="Checking"
  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. else
  20. status=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:")
  21. fi