command_dev_detect_ldd.sh 1.6 KB

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