command_restart.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # LinuxGSM command_restart.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Restarts the server.
  7. commandname="RESTART"
  8. commandaction="Restarting"
  9. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  10. fn_firstcommand_set
  11. info_game.sh
  12. if [ "${stoponlyifnoplayers}" == "on" ]; then
  13. if [ "${querymode}" == "2" ] || [ "${querymode}" == "3" ]; then
  14. for queryip in "${queryips[@]}"; do
  15. query_gamedig.sh
  16. if [ "${querystatus}" == "0" ]; then
  17. if [ -n "${gdplayers}" ] && [ "${gdplayers}" -ne 0 ]; then
  18. fn_print_info_nl "${gdplayers} players are on the server: restart postponed"
  19. fn_script_log_info "${gdplayers} players are on the server: restart postponed"
  20. echo "${gdplayers}" > "${lockdir:?}/${selfname}-player-numbers.lock"
  21. date '+%s' > "${lockdir:?}/${selfname}-restart-request.lock"
  22. core_exit.sh
  23. fi
  24. fi
  25. done
  26. fi
  27. fi
  28. exitbypass=1
  29. command_stop.sh
  30. command_start.sh
  31. fn_firstcommand_reset
  32. core_exit.sh