4
0

core_exit.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # LGSM core_exit.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. # Description: Handles exiting of LGSM by running and reporting an exit code.
  6. fn_exit_dev_debug(){
  7. if [ -f "${rootdir}/.dev-debug" ]; then
  8. echo ""
  9. echo "${function_selfname} exiting with code: ${exitcode}"
  10. fi
  11. }
  12. if [ -n "${exitbypass}" ]; then
  13. unset exitbypass
  14. elif [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then
  15. if [ "${exitcode}" == "1" ]; then
  16. fn_script_log_fatal "${function_selfname} exiting with code: ${exitcode}"
  17. elif [ "${exitcode}" == "2" ]; then
  18. fn_script_log_error "${function_selfname} exiting with code: ${exitcode}"
  19. elif [ "${exitcode}" == "3" ]; then
  20. fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}"
  21. else
  22. fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}"
  23. fi
  24. fn_exit_dev_debug
  25. # remove trap.
  26. trap - INT
  27. exit ${exitcode}
  28. else
  29. exitcode=0
  30. fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}"
  31. fn_exit_dev_debug
  32. # remove trap.
  33. trap - INT
  34. exit ${exitcode}
  35. fi