4
0

command_dev_detect_ldd.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # LinuxGSM command_dev_detect_ldd.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: http://linuxgsm.com/contrib
  5. # Website: https://linuxgsm.com
  6. # Description: Automatically detects required deps using ldd.
  7. # Can check a file or directory recursively.
  8. commandname="DEV-DETECT-LDD"
  9. commandaction="Developer detect ldd"
  10. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  11. fn_firstcommand_set
  12. echo -e "================================="
  13. echo -e "Shared Object dependencies Checker"
  14. echo -e "================================="
  15. if [ -z "${serverfiles}" ]; then
  16. dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
  17. fi
  18. if [ -d "${serverfiles}" ]; then
  19. echo -e "Checking directory: "
  20. echo -e "${serverfiles}"
  21. elif [ -f "${serverfiles}" ]; then
  22. echo -e "Checking file: "
  23. echo -e "${serverfiles}"
  24. fi
  25. echo -e ""
  26. touch "${tmpdir}/detect_ldd.tmp"
  27. touch "${tmpdir}/detect_ldd_not_found.tmp"
  28. files=$(find "${serverfiles}" | wc -l)
  29. find "${serverfiles}" -type f -print0 |
  30. while IFS= read -r -d $'\0' line; do
  31. if ldd "${line}" 2>/dev/null | grep -v "not a dynamic executable"
  32. then
  33. echo -e "${line}" >> "${tmpdir}/detect_ldd.tmp"
  34. ldd "${line}" 2>/dev/null | grep -v "not a dynamic executable" >> "${tmpdir}/detect_ldd.tmp"
  35. if ldd "${line}" 2>/dev/null | grep -v "not a dynamic executable" | grep "not found"
  36. then
  37. echo -e "${line}" >> "${tmpdir}/detect_ldd_not_found.tmp"
  38. ldd "${line}" 2>/dev/null | grep -v "not a dynamic executable" | grep "not found" >> "${tmpdir}/detect_ldd_not_found.tmp"
  39. fi
  40. fi
  41. echo -n "$i / $files" $'\r'
  42. ((i++))
  43. done
  44. echo -e ""
  45. echo -e ""
  46. echo -e "All"
  47. echo -e "================================="
  48. cat "${tmpdir}/detect_ldd.tmp"
  49. echo -e ""
  50. echo -e "Not Found"
  51. echo -e "================================="
  52. cat "${tmpdir}/detect_ldd_not_found.tmp"
  53. rm -f "${tmpdir:?}/detect_ldd.tmp"
  54. rm -f "${tmpdir:?}/detect_ldd_not_found.tmp"
  55. core_exit.sh