command_restart.sh 1014 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # LinuxGSM command_restart.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://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. check.sh
  12. info_game.sh
  13. check_players_online.sh
  14. if [ -n "${playersonline}" ]; then
  15. fn_print_info_nl "${playersonline} players are on the server: restart postponed"
  16. fn_script_log_info "${playersonline} players are on the server: restart postponed"
  17. echo "${playersonline}" > "${lockdir:?}/${selfname}-player-numbers.lock"
  18. date '+%s' > "${lockdir:?}/${selfname}-restart-request.lock"
  19. core_exit.sh
  20. fi
  21. # Clear any pending restart request now that the restart is actually proceeding,
  22. # so a stale lock doesn't trigger a repeat restart on the next monitor run.
  23. rm -f "${lockdir:?}/${selfname}-restart-request.lock"
  24. exitbypass=1
  25. command_stop.sh
  26. command_start.sh
  27. fn_firstcommand_reset
  28. core_exit.sh