Instructions to set up a basic LAMP+SSH server environment
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.7 KiB

6 years ago
  1. #!/bin/bash
  2. # SCRIPT DESCRIPTION:
  3. # This bash script lists all commands/executables included in a package defined in PACKAGES array below.
  4. ###################################################
  5. # System packages to look for commands in:
  6. PACKAGES=(coreutils findutils util-linux)
  7. # Debian-specific command syntax for listing files belonging to a package
  8. # This syntax does not apply in other Linux distributions using other than dpkg solutions.
  9. LIST_COMMAND='dpkg -L'
  10. ###################################################
  11. # Loop through each package listed in PACKAGES bash array above
  12. # For each package, use another loop to go through each file listed in pathes defined by file mimetype
  13. #
  14. for pkg in ${PACKAGES[*]}; do
  15. for file in $($LIST_COMMAND $pkg); do
  16. WHATBIN=$(file --mime-type $file | grep x\-sharedlib | awk -F ":" '{print $1}' | sed '/\.so/d' | awk -F '/' '{print $(NF)}')
  17. # whatis command gets confused with an empty input. Avoid these situations.
  18. if [[ ! -z $WHATBIN ]]; then
  19. whatis $WHATBIN | sed 's/([0-9a-zA-Z])//'
  20. fi
  21. done
  22. done | sort
  23. ###################################################
  24. ## DEPRECATED
  25. ## All bin folders listed in PATH global variable.
  26. ## Remove quotation marks with sed
  27. ## Replace : with |\ for grep command
  28. ## Add each directory path into the exdirs array
  29. ## Start from array index 0 (dirnum) and increase the number in the loop with 'let dirnum++' command
  30. ##
  31. #dirnum=0
  32. #for exdir in $(export -p | grep 'declare -x PATH' | awk -F '=' '{print $2}' | sed 's/"//g' | tr ':' '|\'); do
  33. # exdirs[$dirnum]=$exdir
  34. # let dirnum++
  35. #done
  36. ## DEPRECATED
  37. ## DEPRECATED
  38. # for cmd in $($LIST_COMMAND $pkg | grep -E "${exdirs[*]}" | awk -F '/' '{print $(NF)}'); do
  39. # whatis $cmd | sed 's/([0-9a-zA-Z])//'
  40. # done | sort
  41. ## DEPRECATED