]> git.rmz.io Git - dotfiles.git/blob - bin/socheck
lazyvim: disable LazyVim
[dotfiles.git] / bin / socheck
1 #!/bin/bash
2
3 version="0.1"
4
5 function usage ()
6 {
7 echo "Usage : $0 [options] [PATH]
8 Checks installed libraries for missing dynamic links.
9
10 Options:
11 -d,--depth Max depth to search
12 -h,--help Display this message
13 -v,--version Display script version"
14 }
15
16 checkso() {
17 for f in ${@}; do
18 if sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ldd $f | grep -q "not found"; then
19 echo "$(LC_ALL=C pacman -Qoq $f) $f seems broken!"
20 fi
21 done
22 }
23
24 # Parse arguments
25 declare -a args
26 while [[ $# > 0 ]]; do
27 opt="$1"
28
29 case $opt in
30 -d|--depth) depth=$2; shift 2 ;;
31 -h|--help) usage; exit 0 ;;
32 -v|--version) echo "$0 -- Version $version"; exit 0 ;;
33 -* )
34 echo -e "\n Option does not exist : $opt\n"
35 usage; exit 1 ;;
36
37 *) args+=($opt); shift ;;
38 esac
39 done
40 path="${args[0]}"
41
42 declare -a findopts
43 [[ $depth ]] && findopts+=(-maxdepth "$depth")
44
45 sudo -v
46
47 echo "${findopts[@]}"
48 echo "Searching broken binaries...."
49 binpath=${path:-/usr/bin}
50 bins=( $(find "$binpath" "${findopts[@]}" -type f -executable) )
51 checkso ${bins[@]}
52
53 echo " "
54 echo "Searching broken libs...."
55 libpath=${path:-/usr/lib}
56 libs=( $(find $libpath "${findopts[@]}" -name '*.so' -type f -executable) )
57 checkso ${libs[@]}