fn_deps_detect 5.6 KB

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