4
0

command_debug.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/bash
  2. # LinuxGSM command_debug.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Runs the server without tmux and directly from the terminal.
  7. commandname="DEBUG"
  8. commandaction="Debuging"
  9. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  10. fn_firstcommand_set
  11. # Trap to remove lockfile on quit.
  12. fn_lockfile_trap(){
  13. # Remove lockfile.
  14. rm -f "${lockdir:?}/${selfname}.lock"
  15. # resets terminal. Servers can sometimes mess up the terminal on exit.
  16. reset
  17. fn_print_dots "Stopping debug"
  18. fn_print_ok_nl "Stopping debug"
  19. fn_script_log_pass "Stopping debug"
  20. # remove trap.
  21. trap - INT
  22. core_exit.sh
  23. }
  24. check.sh
  25. fix.sh
  26. info_distro.sh
  27. info_config.sh
  28. # NOTE: Check if works with server without parms. Could be intergrated in to info_parms.sh.
  29. fn_parms
  30. fn_print_header
  31. {
  32. echo -e "${lightblue}Distro:\t\t${default}${distroname}"
  33. echo -e "${lightblue}Arch:\t\t${default}${arch}"
  34. echo -e "${lightblue}Kernel:\t\t${default}${kernel}"
  35. echo -e "${lightblue}Hostname:\t\t${default}${HOSTNAME}"
  36. echo -e "${lightblue}tmux:\t\t${default}${tmuxv}"
  37. echo -e "${lightblue}Avg Load:\t\t${default}${load}"
  38. echo -e "${lightblue}Free Memory:\t\t${default}${physmemfree}"
  39. echo -e "${lightblue}Free Disk:\t\t${default}${availspace}"
  40. } | column -s $'\t' -t
  41. # glibc required.
  42. if [ "${glibc}" ]; then
  43. if [ "${glibc}" == "null" ]; then
  44. # Glibc is not required.
  45. :
  46. elif [ -z "${glibc}" ]; then
  47. echo -e "${lightblue}glibc required:\t${red}UNKNOWN${default}"
  48. elif [ "$(printf '%s\n'${glibc}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibc}" ]; then
  49. echo -e "${lightblue}glibc required:\t${red}${glibc} ${default}(${red}distro glibc ${glibcversion} too old${default})"
  50. else
  51. echo -e "${lightblue}glibc required:\t${green}${glibc}${default}"
  52. fi
  53. fi
  54. # Server IP
  55. echo -e "${lightblue}Game Server IP:\t${default}${ip}:${port}"
  56. # External server IP.
  57. if [ "${extip}" ]; then
  58. if [ "${ip}" != "${extip}" ]; then
  59. echo -e "${lightblue}Internet IP:\t${default}${extip}:${port}"
  60. fi
  61. fi
  62. # Server password.
  63. if [ "${serverpassword}" ]; then
  64. echo -e "${lightblue}Server password:\t${default}${serverpassword}"
  65. fi
  66. echo -e "${lightblue}Start parameters:${default}"
  67. if [ "${engine}" == "source" ]||[ "${engine}" == "goldsrc" ]; then
  68. echo -e "${executable} ${parms} -debug"
  69. elif [ "${engine}" == "quake" ]; then
  70. echo -e "${executable} ${parms} -condebug"
  71. else
  72. echo -e "${preexecutable} ${executable} ${parms}"
  73. fi
  74. echo -e ""
  75. echo -e "Use for identifying server issues only!"
  76. echo -e "Press CTRL+c to drop out of debug mode."
  77. fn_print_warning_nl "If ${selfname} is already running it will be stopped."
  78. echo -e ""
  79. if ! fn_prompt_yn "Continue?" Y; then
  80. exitcode=0
  81. core_exit.sh
  82. fi
  83. fn_print_info_nl "Stopping any running servers"
  84. fn_script_log_info "Stopping any running servers"
  85. exitbypass=1
  86. command_stop.sh
  87. fn_firstcommand_reset
  88. unset exitbypass
  89. fn_print_dots "Starting debug"
  90. fn_script_log_info "Starting debug"
  91. fn_print_ok_nl "Starting debug"
  92. # Create lockfile.
  93. date '+%s' > "${lockdir}/${selfname}.lock"
  94. echo "${version}" >> "${lockdir}/${selfname}.lock"
  95. echo "${port}" >> "${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. # shellcheck disable=SC2086
  111. ${preexecutable} ${executable} ${parms}
  112. fi
  113. fn_lockfile_trap
  114. fn_print_dots "Stopping debug"
  115. fn_print_ok_nl "Stopping debug"
  116. fn_script_log_info "Stopping debug"
  117. core_exit.sh