command_debug.sh 3.7 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. fn_commandname(){
  7. commandname="DEBUG"
  8. commandaction="Debuging"
  9. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  10. }
  11. fn_commandname
  12. # Trap to remove lockfile on quit.
  13. fn_lockfile_trap(){
  14. # Remove lockfile.
  15. rm -f "${lockdir:?}/${selfname}.lock"
  16. # resets terminal. Servers can sometimes mess up the terminal on exit.
  17. reset
  18. fn_print_dots "Stopping debug"
  19. fn_print_ok_nl "Stopping debug"
  20. fn_script_log_pass "Stopping debug"
  21. # remove trap.
  22. trap - INT
  23. core_exit.sh
  24. }
  25. check.sh
  26. fix.sh
  27. info_distro.sh
  28. info_config.sh
  29. # NOTE: Check if works with server without parms. Could be intergrated in to info_parms.sh.
  30. fn_parms
  31. fn_print_header
  32. {
  33. echo -e "${lightblue}Distro:\t\t${default}${distroname}"
  34. echo -e "${lightblue}Arch:\t\t${default}${arch}"
  35. echo -e "${lightblue}Kernel:\t\t${default}${kernel}"
  36. echo -e "${lightblue}Hostname:\t\t${default}${HOSTNAME}"
  37. echo -e "${lightblue}tmux:\t\t${default}${tmuxv}"
  38. echo -e "${lightblue}Avg Load:\t\t${default}${load}"
  39. echo -e "${lightblue}Free Memory:\t\t${default}${physmemfree}"
  40. echo -e "${lightblue}Free Disk:\t\t${default}${availspace}"
  41. } | column -s $'\t' -t
  42. # glibc required.
  43. if [ "${glibc}" ]; then
  44. if [ "${glibc}" == "null" ]; then
  45. # Glibc is not required.
  46. :
  47. elif [ -z "${glibc}" ]; then
  48. echo -e "${lightblue}glibc required:\t${red}UNKNOWN${default}"
  49. elif [ "$(printf '%s\n'${glibc}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibc}" ]; then
  50. echo -e "${lightblue}glibc required:\t${red}${glibc} ${default}(${red}distro glibc ${glibcversion} too old${default})"
  51. else
  52. echo -e "${lightblue}glibc required:\t${green}${glibc}${default}"
  53. fi
  54. fi
  55. # Server IP
  56. if [ "${multiple_ip}" == "1" ]; then
  57. echo -e "${lightblue}Server IP:\t${default}NOT SET"
  58. else
  59. echo -e "${lightblue}Server IP:\t${default}${ip}:${port}"
  60. fi
  61. # External server IP.
  62. if [ "${extip}" ]; then
  63. if [ "${ip}" != "${extip}" ]; then
  64. echo -e "${lightblue}Internet IP:\t${default}${extip}:${port}"
  65. fi
  66. fi
  67. # Server password.
  68. if [ "${serverpassword}" ]; then
  69. echo -e "${lightblue}Server password:\t${default}${serverpassword}"
  70. fi
  71. echo -e "${lightblue}Start parameters:${default}"
  72. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsrc" ]; then
  73. echo -e "${executable} ${parms} -debug"
  74. else
  75. echo -e "${executable} ${parms}"
  76. fi
  77. echo -e ""
  78. echo -e "Use for identifying server issues only!"
  79. echo -e "Press CTRL+c to drop out of debug mode."
  80. fn_print_warning_nl "If ${selfname} is already running it will be stopped."
  81. echo -e ""
  82. if ! fn_prompt_yn "Continue?" Y; then
  83. return
  84. fi
  85. fn_print_info_nl "Stopping any running servers"
  86. fn_script_log_info "Stopping any running servers"
  87. exitbypass=1
  88. command_stop.sh
  89. fn_commandname
  90. unset exitbypass
  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' > "${lockdir}/${selfname}.lock"
  96. fn_script_log_info "Lockfile generated"
  97. fn_script_log_info "${lockdir}/${selfname}.lock"
  98. cd "${executabledir}" || exit
  99. # Note: do not add double quotes to ${executable} ${parms}.
  100. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsrc" ]; then
  101. ${executable} ${parms} -debug
  102. elif [ "${shortname}" == "arma3" ]; then
  103. # Arma3 requires semicolons in the module list, which need to
  104. # be escaped for regular (tmux) loading, but need to be
  105. # stripped when loading straight from the console.
  106. ${executable} ${parms//\\;/;}
  107. elif [ "${engine}" == "quake" ]; then
  108. ${executable} ${parms} -condebug
  109. else
  110. ${executable} ${parms}
  111. fi
  112. fn_lockfile_trap
  113. fn_print_dots "Stopping debug"
  114. fn_print_ok_nl "Stopping debug"
  115. fn_script_log_info "Stopping debug"
  116. core_exit.sh