fn_deps_detect 3.8 KB

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