command_debug.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 "${blue}Distro:\t${default}${distroname}"
  29. echo -e "${blue}Arch:\t${default}${arch}"
  30. echo -e "${blue}Kernel:\t${default}${kernel}"
  31. echo -e "${blue}Hostname:\t${default}$HOSTNAME"
  32. echo -e "${blue}tmux:\t${default}${tmuxv}"
  33. echo -e "${blue}Avg Load:\t${default}${load}"
  34. echo -e "${blue}Free Memory:\t${default}${physmemfree}"
  35. echo -e "${blue}Free Disk:\t${default}${availspace}"
  36. # GLIBC required
  37. if [ -n "${glibcrequired}" ]; then
  38. if [ "${glibcrequired}" == "NOT REQUIRED" ]; then
  39. :
  40. elif [ "${glibcrequired}" == "UNKNOWN" ]; then
  41. echo -e "${blue}GLIBC required:\t${red}${glibcrequired}"
  42. elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then
  43. if [ "${glibcfix}" == "yes" ]; then
  44. echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${green}Using GLIBC fix${default})"
  45. else
  46. echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${red}GLIBC version too old${default})"
  47. fi
  48. else
  49. echo -e "${blue}GLIBC required:\t${green}${glibcrequired}${default}"
  50. fi
  51. fi
  52. # Server ip
  53. echo -e "${blue}Server IP:\t${default}${ip}:${port}"
  54. # Server password
  55. if [ -n "${serverpassword}" ]; then
  56. echo -e "${blue}Server password:\t${default}${serverpassword}"
  57. fi
  58. echo ""
  59. echo "Start parameters:"
  60. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
  61. echo "${executable} ${parms} -debug"
  62. else
  63. echo "${executable} ${parms}"
  64. fi
  65. echo ""
  66. echo -e "Use for identifying server issues only!"
  67. echo -e "Press CTRL+c to drop out of debug mode."
  68. fn_print_warning_nl "If ${servicename} is already running it will be stopped."
  69. echo ""
  70. while true; do
  71. read -e -i "y" -p "Continue? [Y/n]" yn
  72. case $yn in
  73. [Yy]* ) break;;
  74. [Nn]* ) echo Exiting; return;;
  75. * ) echo "Please answer yes or no.";;
  76. esac
  77. done
  78. fn_print_info_nl "Stopping any running servers"
  79. fn_script_log_info "Stopping any running servers"
  80. sleep 1
  81. exitbypass=1
  82. command_stop.sh
  83. fn_print_dots "Starting debug"
  84. fn_script_log_info "Starting debug"
  85. sleep 1
  86. fn_print_ok_nl "Starting debug"
  87. # create lock file.
  88. date > "${rootdir}/${lockselfname}"
  89. # trap to remove lockfile on quit.
  90. trap fn_lockfile_trap INT
  91. cd "${executabledir}"
  92. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
  93. ${executable} ${parms} -debug
  94. else
  95. ${executable} ${parms}
  96. fi
  97. # remove trap.
  98. trap - INT
  99. core_exit.sh