add find_binary()

* centos does not have which installed by default. adds functionality
  to emulate it.

  part of the fix for:
  https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/213
This commit is contained in:
Stuart Cardall 2018-09-29 12:53:56 +00:00
parent bcb746137b
commit ebaaaf3a7a
No known key found for this signature in database
GPG key ID: AEB857F1C891D0C6

View file

@ -284,9 +284,22 @@ check_args() {
esac
}
find_binary() {
local x= path= bin=$1 bin_paths='/usr/bin /usr/local/bin /usr/sbin /usr/local/sbin /root/bin /root/.bin'
for x in $bin_paths; do
path="$x/$bin"
if [ -x $path ]; then
echo $path
return
fi
done
}
check_depends() {
# centos also does not have which by default
if [ ! -x /usr/bin/curl ]; then
# centos does not have which by default
if [ -z $(find_binary curl) ]; then
printf "${BOLDRED}ERROR${RESET}: $0 requires: 'curl' => ${BOLDWHITE}cannot check remote version.${RESET}\n"
exit 1
fi