command_debug.sh 2.0 KB

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