fn_deps_detect 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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" ]||[ "${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. executable=ucc-bin-real
  23. elif [ "${executable}" == "./ts3server_startscript.sh" ];then
  24. executable=ts3server_linux_amd64
  25. fi
  26. readelf -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > ${rootdir}/.depdetect_readelf
  27. echo "yum install " > ${rootdir}/.depdetect_centos_list_uniq
  28. echo "apt-get install " > ${rootdir}/.depdetect_ubuntu_list_uniq
  29. echo "apt-get install " > ${rootdir}/.depdetect_debian_list_uniq
  30. while read lib; do
  31. sharedlib=${lib}
  32. 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
  33. echo "glibc.i686" >> ${rootdir}/.depdetect_centos_list
  34. echo "lib32gcc1" >> ${rootdir}/.depdetect_ubuntu_list
  35. echo "lib32gcc1" >> ${rootdir}/.depdetect_debian_list
  36. elif [ "${lib}" == "libstdc++.so.6" ];then
  37. echo "libstdc++.i686" >> ${rootdir}/.depdetect_centos_list
  38. echo "libstdc++6:i386" >> ${rootdir}/.depdetect_ubuntu_list
  39. echo "libstdc++6:i386" >> ${rootdir}/.depdetect_debian_list
  40. elif [ "${lib}" == "libstdc++.so.5" ];then
  41. echo "compat-libstdc++-33.i686" >> ${rootdir}/.depdetect_centos_list
  42. echo "libstdc++5:i386" >> ${rootdir}/.depdetect_ubuntu_list
  43. echo "libstdc++5:i386" >> ${rootdir}/.depdetect_debian_list
  44. elif [ "${lib}" == "libspeex.so.1" ]||[ "${lib}" == "libspeexdsp.so.1" ];then
  45. echo "speex.i686" >> ${rootdir}/.depdetect_centos_list
  46. echo "speex:i386" >> ${rootdir}/.depdetect_ubuntu_list
  47. echo "speex:i386" >> ${rootdir}/.depdetect_debian_list
  48. elif [ "${lib}" == "libtbb.so.2" ];then
  49. echo "tbb.i686" >> ${rootdir}/.depdetect_centos_list
  50. echo "libtbb2:i386" >> ${rootdir}/.depdetect_ubuntu_list
  51. echo "libtbb2:i386" >> ${rootdir}/.depdetect_debian_list
  52. 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" ];then
  53. # Known shared libs what dont requires dependencies
  54. :
  55. else
  56. unknownlib=1
  57. echo "${lib}" >> ${rootdir}/.depdetect_unknown
  58. fi
  59. done < ${rootdir}/.depdetect_readelf
  60. sort ${rootdir}/.depdetect_centos_list | uniq >> ${rootdir}/.depdetect_centos_list_uniq
  61. sort ${rootdir}/.depdetect_ubuntu_list | uniq >> ${rootdir}/.depdetect_ubuntu_list_uniq
  62. sort ${rootdir}/.depdetect_debian_list | uniq >> ${rootdir}/.depdetect_debian_list_uniq
  63. if [ "${unknownlib}" == "1" ];then
  64. sort ${rootdir}/.depdetect_unknown | uniq >> ${rootdir}/.depdetect_unknown_uniq
  65. fi
  66. awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_centos_list_uniq > ${rootdir}/.depdetect_centos_line
  67. awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_ubuntu_list_uniq > ${rootdir}/.depdetect_ubuntu_line
  68. awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_debian_list_uniq > ${rootdir}/.depdetect_debian_line
  69. echo ""
  70. echo "Required Dependencies"
  71. echo "================================="
  72. echo "${executable}"
  73. echo ""
  74. echo "CentOS"
  75. echo "================================="
  76. cat ${rootdir}/.depdetect_centos_line
  77. echo ""
  78. echo ""
  79. echo "Ubuntu"
  80. echo "================================="
  81. cat ${rootdir}/.depdetect_ubuntu_line
  82. echo ""
  83. echo ""
  84. echo "Debian"
  85. echo "================================="
  86. cat ${rootdir}/.depdetect_debian_line
  87. echo ""
  88. if [ "${unknownlib}" == "1" ];then
  89. echo ""
  90. echo "Unknown shared Library"
  91. echo "================================="
  92. cat ${rootdir}/.depdetect_unknown
  93. fi
  94. echo ""
  95. echo "Required Librarys"
  96. echo "================================="
  97. sort ${rootdir}/.depdetect_readelf |uniq
  98. echo -en "\n"
  99. rm -f ${rootdir}/.depdetect_centos_line
  100. rm -f ${rootdir}/.depdetect_centos_list
  101. rm -f ${rootdir}/.depdetect_centos_list
  102. rm -f ${rootdir}/.depdetect_centos_list_uniq
  103. rm -f ${rootdir}/.depdetect_debian_list
  104. rm -f ${rootdir}/.depdetect_debian_list_uniq
  105. rm -f ${rootdir}/.depdetect_readelf
  106. rm -f ${rootdir}/.depdetect_ubuntu_list
  107. rm -f ${rootdir}/.depdetect_ubuntu_list_uniq
  108. rm -f ${rootdir}/.depdetect_unknown
  109. rm -f ${rootdir}/.depdetect_unknown_uniq