command_debug.sh 3.3 KB

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