command_debug.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. local 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 "${glibc}" ]; then
  36. if [ "${glibc}" == "null" ]; then
  37. # Glibc is not required.
  38. :
  39. elif [ -z "${glibc}" ]; then
  40. echo -e "${blue}glibc required:\t${red}UNKNOWN${default}"
  41. elif [ "$(printf '%s\n'${glibc}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibc}" ]; then
  42. echo -e "${blue}glibc required:\t${red}${glibc} ${default}(${red}distro glibc ${glibcversion} too old${default})"
  43. else
  44. echo -e "${blue}glibc required:\t${green}${glibc}${default}"
  45. fi
  46. fi
  47. # Server IP
  48. if [ "${multiple_ip}" == "1" ]; then
  49. echo -e "${blue}Server IP:\t${default}NOT SET"
  50. else
  51. echo -e "${blue}Server IP:\t${default}${ip}:${port}"
  52. fi
  53. # External server IP.
  54. if [ -n "${extip}" ]; then
  55. if [ "${ip}" != "${extip}" ]; then
  56. echo -e "${blue}Internet IP:\t${default}${extip}:${port}"
  57. fi
  58. fi
  59. # Listed on Master Server.
  60. if [ "${displaymasterserver}" ];then
  61. if [ "${displaymasterserver}" == "true" ];then
  62. echo -e "${blue}Master Server:\t${green}${displaymasterserver}${default}"
  63. else
  64. echo -e "${blue}Master Server:\t${red}${displaymasterserver}${default}"
  65. fi
  66. fi
  67. # Server password.
  68. if [ -n "${serverpassword}" ]; then
  69. echo -e "${blue}Server password:\t${default}${serverpassword}"
  70. fi
  71. echo ""
  72. echo "Start parameters:"
  73. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
  74. echo "${executable} ${parms} -debug"
  75. else
  76. echo "${executable} ${parms}"
  77. fi
  78. echo ""
  79. echo -e "Use for identifying server issues only!"
  80. echo -e "Press CTRL+c to drop out of debug mode."
  81. fn_print_warning_nl "If ${servicename} is already running it will be stopped."
  82. echo ""
  83. if ! fn_prompt_yn "Continue?" Y; then
  84. echo Exiting; return
  85. fi
  86. fn_print_info_nl "Stopping any running servers"
  87. fn_script_log_info "Stopping any running servers"
  88. exitbypass=1
  89. command_stop.sh
  90. fn_print_dots "Starting debug"
  91. fn_script_log_info "Starting debug"
  92. fn_print_ok_nl "Starting debug"
  93. # Create lockfile.
  94. date '+%s' > "${rootdir}/${lockselfname}"
  95. fn_script_log_info "Lockfile generated"
  96. fn_script_log_info "${rootdir}/${lockselfname}"
  97. # trap to remove lockfile on quit.
  98. trap fn_lockfile_trap INT
  99. cd "${executabledir}" || exit
  100. # Note: do not add double quotes to ${executable} ${parms}.
  101. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
  102. ${executable} ${parms} -debug
  103. elif [ "${engine}" == "realvirtuality" ]; then
  104. # Arma3 requires semicolons in the module list, which need to
  105. # be escaped for regular (tmux) loading, but need to be
  106. # stripped when loading straight from the console.
  107. ${executable} ${parms//\\;/;}
  108. elif [ "${engine}" == "quake" ]; then
  109. ${executable} ${parms} -condebug
  110. else
  111. ${executable} ${parms}
  112. fi
  113. fn_print_dots "Stopping debug"
  114. fn_print_ok_nl "Stopping debug"
  115. # remove trap.
  116. trap - INT
  117. core_exit.sh