command_dev_detect_deps.sh 5.6 KB

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