command_debug.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash
  2. # LinuxGSM command_debug.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Runs the server without tmux and directly from the terminal.
  6. local commandname="DEBUG"
  7. local commandaction="Debug"
  8. function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  9. # Trap to remove lockfile on quit.
  10. fn_lockfile_trap(){
  11. # Remove lockfile
  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. info_config.sh
  23. # NOTE: Check if works with server without parms. Could be intergrated in to info_parms.sh
  24. fn_parms
  25. fn_print_header
  26. echo -e "${blue}Distro:\t${default}${distroname}"
  27. echo -e "${blue}Arch:\t${default}${arch}"
  28. echo -e "${blue}Kernel:\t${default}${kernel}"
  29. echo -e "${blue}Hostname:\t${default}${HOSTNAME}"
  30. echo -e "${blue}tmux:\t${default}${tmuxv}"
  31. echo -e "${blue}Avg Load:\t${default}${load}"
  32. echo -e "${blue}Free Memory:\t${default}${physmemfree}"
  33. echo -e "${blue}Free Disk:\t${default}${availspace}"
  34. # GLIBC required
  35. if [ -n "${glibcrequired}" ]; then
  36. if [ "${glibcrequired}" == "NOT REQUIRED" ]; then
  37. :
  38. elif [ "${glibcrequired}" == "UNKNOWN" ]; then
  39. echo -e "${blue}GLIBC required:\t${red}${glibcrequired}"
  40. elif [ "$(printf '%s\n'${glibcrequired}'\n' "${glibcversion}" | sort -V | head -n 1)" != "${glibcrequired}" ]; then
  41. if [ "${glibcfix}" == "yes" ]; then
  42. echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${green}Using GLIBC fix${default})"
  43. else
  44. echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${red}GLIBC version too old${default})"
  45. fi
  46. else
  47. echo -e "${blue}GLIBC required:\t${green}${glibcrequired}${default}"
  48. fi
  49. fi
  50. # Server ip
  51. echo -e "${blue}Server IP:\t${default}${ip}:${port}"
  52. # External server ip
  53. if [ -n "${extip}" ]; then
  54. if [ "${ip}" != "${extip}" ]; then
  55. echo -e "${blue}Internet IP:\t${default}${extip}:${port}"
  56. fi
  57. fi
  58. # Server password
  59. if [ -n "${serverpassword}" ]; then
  60. echo -e "${blue}Server password:\t${default}${serverpassword}"
  61. fi
  62. echo ""
  63. echo "Start parameters:"
  64. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
  65. echo "${executable} ${parms} -debug"
  66. else
  67. echo "${executable} ${parms}"
  68. fi
  69. echo ""
  70. echo -e "Use for identifying server issues only!"
  71. echo -e "Press CTRL+c to drop out of debug mode."
  72. fn_print_warning_nl "If ${servicename} is already running it will be stopped."
  73. echo ""
  74. if ! fn_prompt_yn "Continue?" Y; then
  75. echo Exiting; return
  76. fi
  77. fn_print_info_nl "Stopping any running servers"
  78. fn_script_log_info "Stopping any running servers"
  79. sleep 0.5
  80. exitbypass=1
  81. command_stop.sh
  82. fn_print_dots "Starting debug"
  83. fn_script_log_info "Starting debug"
  84. sleep 0.5
  85. fn_print_ok_nl "Starting debug"
  86. # Create lockfile
  87. date > "${rootdir}/${lockselfname}"
  88. fn_script_log_info "Lockfile generated"
  89. fn_script_log_info "${rootdir}/${lockselfname}"
  90. # trap to remove lockfile on quit.
  91. trap fn_lockfile_trap INT
  92. cd "${executabledir}" || exit
  93. # Note: do not add double quotes to ${executable} ${parms}
  94. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
  95. ${executable} ${parms} -debug
  96. elif [ "${engine}" == "realvirtuality" ]; then
  97. # Arma3 requires semicolons in the module list, which need to
  98. # be escaped for regular (tmux) loading, but need to be
  99. # stripped when loading straight from the console.
  100. ${executable} ${parms//\\;/;}
  101. else
  102. ${executable} ${parms}
  103. fi
  104. fn_print_dots "Stopping debug"
  105. sleep 1
  106. fn_print_ok_nl "Stopping debug"
  107. # remove trap.
  108. trap - INT
  109. core_exit.sh