command_dev_detect_deps.sh 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/bin/bash
  2. # LinuxGSM command_dev_detect_deps.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://gameservermanagers.com
  5. # Description: Detects dependencies the server binary requires.
  6. local commandname="DEPS-DETECT"
  7. local commandaction="Deps-Detect"
  8. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
  9. check.sh
  10. cd "${executabledir}"
  11. if [ "${executable}" == "./hlds_run" ]; then
  12. executable=hlds_linux
  13. elif [ "${executable}" == "./srcds_run" ]||[ "${executable}" == "./dabds.sh" ]||[ "${executable}" == "./srcds_run.sh" ]; then
  14. executable=srcds_linux
  15. elif [ "${executable}" == "./server_linux32" ]; then
  16. executable=libSpark_Core.so
  17. elif [ "${executable}" == "./runSam3_DedicatedServer.sh" ]; then
  18. executable=Sam3_DedicatedServer
  19. elif [ "${executable}" == "./7DaysToDie.sh" ]; then
  20. executable=7DaysToDie.x86
  21. elif [ "${executable}" == "./ucc-bin" ]; then
  22. if [ -f "${executabledir}/ucc-bin-real" ]; then
  23. executable=ucc-bin-real
  24. elif [ -f "${executabledir}/ut2004-bin" ]; then
  25. executable=ut2004-bin
  26. else
  27. executable=ut-bin
  28. fi
  29. elif [ "${executable}" == "./ts3server_startscript.sh" ]; then
  30. executable=ts3server_linux_amd64
  31. fi
  32. if [ "$(command -v eu-readelf)" ]; then
  33. readelf=eu-readelf
  34. elif [ "$(command -v readelf)" ]; then
  35. readelf=readelf
  36. else
  37. echo "readelf/eu-readelf not installed"
  38. fi
  39. ${readelf} -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > "${tmpdir}/.depdetect_readelf"
  40. echo "yum install " > "${tmpdir}/.depdetect_centos_list_uniq"
  41. echo "apt-get install " > "${tmpdir}/.depdetect_ubuntu_list_uniq"
  42. echo "apt-get install " > "${tmpdir}/.depdetect_debian_list_uniq"
  43. while read lib; do
  44. sharedlib=${lib}
  45. if [ "${lib}" == "libm.so.6" ]||[ "${lib}" == "libc.so.6" ]||[ "${lib}" == "libpthread.so.0" ]||[ "${lib}" == "libdl.so.2" ]||[ "${lib}" == "libnsl.so.1" ]||[ "${lib}" == "libgcc_s.so.1" ]||[ "${lib}" == "librt.so.1" ]||[ "${lib}" == "ld-linux.so.2" ]; then
  46. echo "glibc.i686" >> "${tmpdir}/.depdetect_centos_list"
  47. echo "lib32gcc1" >> "${tmpdir}/.depdetect_ubuntu_list"
  48. echo "lib32gcc1" >> "${tmpdir}/.depdetect_debian_list"
  49. elif [ "${lib}" == "libstdc++.so.6" ]; then
  50. echo "libstdc++.i686" >> "${tmpdir}/.depdetect_centos_list"
  51. echo "libstdc++6:i386" >> "${tmpdir}/.depdetect_ubuntu_list"
  52. echo "libstdc++6:i386" >> "${tmpdir}/.depdetect_debian_list"
  53. elif [ "${lib}" == "libstdc++.so.5" ]; then
  54. echo "compat-libstdc++-33.i686" >> "${tmpdir}/.depdetect_centos_list"
  55. echo "libstdc++5:i386" >> "${tmpdir}/.depdetect_ubuntu_list"
  56. echo "libstdc++5:i386" >> "${tmpdir}/.depdetect_debian_list"
  57. elif [ "${lib}" == "libspeex.so.1" ]||[ "${lib}" == "libspeexdsp.so.1" ]; then
  58. echo "speex.i686" >> "${tmpdir}/.depdetect_centos_list"
  59. echo "speex:i386" >> "${tmpdir}/.depdetect_ubuntu_list"
  60. echo "speex:i386" >> "${tmpdir}/.depdetect_debian_list"
  61. elif [ "${lib}" == "./libSDL-1.2.so.0" ]||[ "${lib}" == "libSDL-1.2.so.0" ]; then
  62. echo "SDL.i686" >> "${tmpdir}/.depdetect_centos_list"
  63. echo "libsdl1.2debian" >> "${tmpdir}/.depdetect_ubuntu_list"
  64. echo "libsdl1.2debian" >> "${tmpdir}/.depdetect_debian_list"
  65. elif [ "${lib}" == "libtbb.so.2" ]; then
  66. echo "tbb.i686" >> "${tmpdir}/.depdetect_centos_list"
  67. echo "libtbb2" >> "${tmpdir}/.depdetect_ubuntu_list"
  68. echo "libtbb2" >> "${tmpdir}/.depdetect_debian_list"
  69. elif [ "${lib}" == "libtier0.so" ]||[ "${lib}" == "Core.so" ]||[ "${lib}" == "Editor.so" ]||[ "${lib}" == "Engine.so" ]||[ "${lib}" == "liblua.so" ]||[ "${lib}" == "libsteam_api.so" ]||[ "${lib}" == "ld-linux-x86-64.so.2" ]||[ "${lib}" == "libPhysX3_x86.so" ]||[ "${lib}" == "libPhysX3Common_x86.so" ]||[ "${lib}" == "libPhysX3Cooking_x86.so" ]; then
  70. # Known shared libs what dont requires dependencies
  71. :
  72. else
  73. unknownlib=1
  74. echo "${lib}" >> "${tmpdir}/.depdetect_unknown"
  75. fi
  76. done < "${tmpdir}/.depdetect_readelf"
  77. sort "${tmpdir}/.depdetect_centos_list" | uniq >> "${tmpdir}/.depdetect_centos_list_uniq"
  78. sort "${tmpdir}/.depdetect_ubuntu_list" | uniq >> "${tmpdir}/.depdetect_ubuntu_list_uniq"
  79. sort "${tmpdir}/.depdetect_debian_list" | uniq >> "${tmpdir}/.depdetect_debian_list_uniq"
  80. if [ "${unknownlib}" == "1" ]; then
  81. sort "${tmpdir}/.depdetect_unknown" | uniq >> "${tmpdir}/.depdetect_unknown_uniq"
  82. fi
  83. awk -vORS=' ' '{ print $1, $2 }' "${tmpdir}/.depdetect_centos_list_uniq" > "${tmpdir}/.depdetect_centos_line"
  84. awk -vORS=' ' '{ print $1, $2 }' "${tmpdir}/.depdetect_ubuntu_list_uniq" > "${tmpdir}/.depdetect_ubuntu_line"
  85. awk -vORS=' ' '{ print $1, $2 }' "${tmpdir}/.depdetect_debian_list_uniq" > "${tmpdir}/.depdetect_debian_line"
  86. echo ""
  87. echo "Required Dependencies"
  88. echo "================================="
  89. echo "${executable}"
  90. echo ""
  91. echo "CentOS"
  92. echo "================================="
  93. cat "${tmpdir}/.depdetect_centos_line"
  94. echo ""
  95. echo ""
  96. echo "Ubuntu"
  97. echo "================================="
  98. cat "${tmpdir}/.depdetect_ubuntu_line"
  99. echo ""
  100. echo ""
  101. echo "Debian"
  102. echo "================================="
  103. cat "${tmpdir}/.depdetect_debian_line"
  104. echo ""
  105. if [ "${unknownlib}" == "1" ]; then
  106. echo ""
  107. echo "Unknown shared Library"
  108. echo "================================="
  109. cat "${tmpdir}/.depdetect_unknown"
  110. fi
  111. echo ""
  112. echo "Required Librarys"
  113. echo "================================="
  114. sort "${tmpdir}/.depdetect_readelf" |uniq
  115. echo ""
  116. echo "ldd"
  117. echo "================================="
  118. ldd ${executable}
  119. echo -en "\n"
  120. rm -f "${tmpdir}/.depdetect_centos_line"
  121. rm -f "${tmpdir}/.depdetect_centos_list"
  122. rm -f "${tmpdir}/.depdetect_centos_list_uniq"
  123. rm -f "${tmpdir}/.depdetect_debian_line"
  124. rm -f "${tmpdir}/.depdetect_debian_list"
  125. rm -f "${tmpdir}/.depdetect_debian_list_uniq"
  126. rm -f "${tmpdir}/.depdetect_ubuntu_line"
  127. rm -f "${tmpdir}/.depdetect_ubuntu_list"
  128. rm -f "${tmpdir}/.depdetect_ubuntu_list_uniq"
  129. rm -f "${tmpdir}/.depdetect_readelf"
  130. rm -f "${tmpdir}/.depdetect_unknown"
  131. rm -f "${tmpdir}/.depdetect_unknown_uniq"
  132. core_exit.sh