From ebaaaf3a7a8ac00bd98955eefec6214316bd11d0 Mon Sep 17 00:00:00 2001 From: Stuart Cardall Date: Sat, 29 Sep 2018 12:53:56 +0000 Subject: [PATCH] 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 --- setup-ngxblocker | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/setup-ngxblocker b/setup-ngxblocker index ac5785bac..44d7455d9 100755 --- a/setup-ngxblocker +++ b/setup-ngxblocker @@ -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