fn_deps_detect 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. # LGSM fn_dep_detect function
  3. # Author: Daniel Gibbs
  4. # Website: http://gameservermanagers.com
  5. # Version: 200615
  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" ];then
  14. executable=srcds_linux
  15. elif [ "${executable}" == "./server_linux32" ];then
  16. executable=libSpark_Core.so
  17. fi
  18. readelf -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > ${rootdir}/.depdetect_readelf
  19. echo "yum install " > ${rootdir}/.depdetect_centos_list_uniq
  20. echo "apt-get install " > ${rootdir}/.depdetect_ubuntu_list_uniq
  21. echo "apt-get install " > ${rootdir}/.depdetect_debian_list_uniq
  22. while read lib; do
  23. sharedlib=${lib}
  24. 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
  25. echo "glibc.i686" >> ${rootdir}/.depdetect_centos_list
  26. echo "lib32gcc1" >> ${rootdir}/.depdetect_ubuntu_list
  27. echo "lib32gcc1" >> ${rootdir}/.depdetect_debian_list
  28. elif [ "${lib}" == "libstdc++.so.6" ];then
  29. echo "libstdc++.i686" >> ${rootdir}/.depdetect_centos_list
  30. echo "libstdc++6:i386" >> ${rootdir}/.depdetect_ubuntu_list
  31. echo "libstdc++6:i386" >> ${rootdir}/.depdetect_debian_list
  32. elif [ "${lib}" == "libstdc++.so.5" ];then
  33. echo "compat-libstdc++-33.i686" >> ${rootdir}/.depdetect_centos_list
  34. echo "libstdc++5:i386" >> ${rootdir}/.depdetect_ubuntu_list
  35. echo "libstdc++5:i386" >> ${rootdir}/.depdetect_debian_list
  36. elif [ "${lib}" == "libspeex.so.1" ]||[ "${lib}" == "libspeexdsp.so.1" ];then
  37. echo "speex.i686" >> ${rootdir}/.depdetect_centos_list
  38. echo "speex:i386" >> ${rootdir}/.depdetect_ubuntu_list
  39. echo "speex:i386" >> ${rootdir}/.depdetect_debian_list
  40. elif [ "${lib}" == "libtbb.so.2" ];then
  41. echo "tbb.i686" >> ${rootdir}/.depdetect_centos_list
  42. echo "libtbb2:i386" >> ${rootdir}/.depdetect_ubuntu_list
  43. echo "libtbb2:i386" >> ${rootdir}/.depdetect_debian_list
  44. elif [ "${lib}" == "libtier0.so" ]||[ "${lib}" == "Core.so" ]||[ "${lib}" == "Editor.so" ]||[ "${lib}" == "Engine.so" ]||[ "${lib}" == "liblua.so" ]||[ "${lib}" == "libsteam_api.so" ];then
  45. # Known shared libs what dont requires dependencies
  46. :
  47. else
  48. unknownlib=1
  49. echo "${lib}" >> ${rootdir}/.depdetect_unknown
  50. fi
  51. done < ${rootdir}/.depdetect_readelf
  52. sort ${rootdir}/.depdetect_centos_list | uniq >> ${rootdir}/.depdetect_centos_list_uniq
  53. sort ${rootdir}/.depdetect_ubuntu_list | uniq >> ${rootdir}/.depdetect_ubuntu_list_uniq
  54. sort ${rootdir}/.depdetect_debian_list | uniq >> ${rootdir}/.depdetect_debian_list_uniq
  55. if [ "${unknownlib}" == "1" ];then
  56. sort ${rootdir}/.depdetect_unknown | uniq >> ${rootdir}/.depdetect_unknown_uniq
  57. fi
  58. awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_centos_list_uniq > ${rootdir}/.depdetect_centos_line
  59. awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_ubuntu_list_uniq > ${rootdir}/.depdetect_ubuntu_line
  60. awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_debian_list_uniq > ${rootdir}/.depdetect_debian_line
  61. echo ""
  62. echo "Required Dependencies"
  63. echo "================================="
  64. echo "${executable}"
  65. echo ""
  66. echo "CentOS"
  67. echo "================================="
  68. cat ${rootdir}/.depdetect_centos_line
  69. echo ""
  70. echo ""
  71. echo "Ubuntu"
  72. echo "================================="
  73. cat ${rootdir}/.depdetect_ubuntu_line
  74. echo ""
  75. echo ""
  76. echo "Debian"
  77. echo "================================="
  78. cat ${rootdir}/.depdetect_debian_line
  79. echo ""
  80. if [ "${unknownlib}" == "1" ];then
  81. echo ""
  82. echo "Unknown shared Library"
  83. echo "================================="
  84. cat ${rootdir}/.depdetect_unknown
  85. fi
  86. echo ""
  87. echo "Required Librarys"
  88. echo "================================="
  89. sort ${rootdir}/.depdetect_readelf |uniq
  90. echo -en "\n"
  91. rm -f ${rootdir}/.depdetect_centos_line
  92. rm -f ${rootdir}/.depdetect_centos_list
  93. rm -f ${rootdir}/.depdetect_centos_list
  94. rm -f ${rootdir}/.depdetect_centos_list_uniq
  95. rm -f ${rootdir}/.depdetect_debian_list
  96. rm -f ${rootdir}/.depdetect_debian_list_uniq
  97. rm -f ${rootdir}/.depdetect_readelf
  98. rm -f ${rootdir}/.depdetect_ubuntu_list
  99. rm -f ${rootdir}/.depdetect_ubuntu_list_uniq
  100. rm -f ${rootdir}/.depdetect_unknown
  101. rm -f ${rootdir}/.depdetect_unknown_uniq