command_debug.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. # LGSM command_debug.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. lgsm_version="210516"
  6. # Description: Runs the server without tmux. Runs direct from the terminal.
  7. local modulename="Debug"
  8. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  9. # Trap to remove lockfile on quit.
  10. fn_lockfile_trap(){
  11. # Remove lock file
  12. rm -f "${rootdir}/${lockselfname}"
  13. # resets terminal. Servers can sometimes mess up the terminal on exit.
  14. reset
  15. core_exit.sh
  16. }
  17. check.sh
  18. fix.sh
  19. info_distro.sh
  20. # NOTE: Check if works with server without parms. Could be intergrated in to info_parms.sh
  21. fn_parms
  22. echo ""
  23. echo "${gamename} Debug"
  24. echo "================================="
  25. echo ""
  26. echo -e "Distro: ${os}"
  27. echo -e "Arch: ${arch}"
  28. echo -e "Kernel: ${kernel}"
  29. echo -e "Hostname: $HOSTNAME"
  30. echo ""
  31. echo "Start parameters:"
  32. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
  33. echo "${executable} ${parms} -debug"
  34. else
  35. echo "${executable} ${parms}"
  36. fi
  37. echo ""
  38. echo -e "Use for identifying server issues only!"
  39. echo -e "Press CTRL+c to drop out of debug mode."
  40. fn_print_warning_nl "If ${servicename} is already running it will be stopped."
  41. echo ""
  42. while true; do
  43. read -e -i "y" -p "Continue? [Y/n]" yn
  44. case $yn in
  45. [Yy]* ) break;;
  46. [Nn]* ) echo Exiting; return;;
  47. * ) echo "Please answer yes or no.";;
  48. esac
  49. done
  50. fn_print_info_nl "Stopping any running servers"
  51. fn_script_log_info "Stopping any running servers"
  52. sleep 1
  53. exitbypass=1
  54. command_stop.sh
  55. fn_print_dots "Starting debug"
  56. fn_script_log_info "Starting debug"
  57. sleep 1
  58. fn_print_ok_nl "Starting debug"
  59. # create lock file.
  60. date > "${rootdir}/${lockselfname}"
  61. # trap to remove lockfile on quit.
  62. trap fn_lockfile_trap INT
  63. cd "${executabledir}"
  64. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
  65. ${executable} ${parms} -debug
  66. else
  67. ${executable} ${parms}
  68. fi
  69. # remove trap.
  70. trap - INT
  71. core_exit.sh