command_debug.sh 3.7 KB

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