4
0

command_dev_detect_ldd.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # LinuxGSM command_dev_detect_ldd.sh module
  3. # Author: Daniel Gibbs
  4. # Contributors: https://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. moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  11. fn_firstcommand_set
  12. fn_messages_separator
  13. echo -e "Shared Object dependencies Checker"
  14. fn_messages_separator
  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"; then
  32. echo -e "${line}" >> "${tmpdir}/detect_ldd.tmp"
  33. ldd "${line}" 2> /dev/null | grep -v "not a dynamic executable" >> "${tmpdir}/detect_ldd.tmp"
  34. if ldd "${line}" 2> /dev/null | grep -v "not a dynamic executable" | grep "not found"; then
  35. echo -e "${line}" >> "${tmpdir}/detect_ldd_not_found.tmp"
  36. ldd "${line}" 2> /dev/null | grep -v "not a dynamic executable" | grep "not found" >> "${tmpdir}/detect_ldd_not_found.tmp"
  37. fi
  38. fi
  39. echo -n "$i / $files" $'\r'
  40. ((i++))
  41. done
  42. echo -e ""
  43. echo -e ""
  44. echo -e "All"
  45. fn_messages_separator
  46. cat "${tmpdir}/detect_ldd.tmp"
  47. echo -e ""
  48. echo -e "Not Found"
  49. fn_messages_separator
  50. cat "${tmpdir}/detect_ldd_not_found.tmp"
  51. rm -f "${tmpdir:?}/detect_ldd.tmp"
  52. rm -f "${tmpdir:?}/detect_ldd_not_found.tmp"
  53. core_exit.sh