command_debug.sh 3.7 KB

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