command_debug.sh 3.9 KB

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