4
0

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