mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-03 19:20:16 +00:00
remove wget dependency
* part of the fix for https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/213
This commit is contained in:
parent
f55911a846
commit
bcb746137b
1 changed files with 4 additions and 22 deletions
|
@ -285,12 +285,6 @@ check_args() {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_depends() {
|
check_depends() {
|
||||||
# centos does not have wget installed by default
|
|
||||||
if ! wget --help >/dev/null 2>&1; then
|
|
||||||
printf "${BOLDRED}ERROR${RESET}: $0 requires: 'wget' => ${BOLDWHITE}cannot download files.${RESET}\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# centos also does not have which by default
|
# centos also does not have which by default
|
||||||
if [ ! -x /usr/bin/curl ]; then
|
if [ ! -x /usr/bin/curl ]; then
|
||||||
printf "${BOLDRED}ERROR${RESET}: $0 requires: 'curl' => ${BOLDWHITE}cannot check remote version.${RESET}\n"
|
printf "${BOLDRED}ERROR${RESET}: $0 requires: 'curl' => ${BOLDWHITE}cannot check remote version.${RESET}\n"
|
||||||
|
@ -354,23 +348,11 @@ get_options() {
|
||||||
INSTALL_INC="$INSTALLER -b $BOTS_DIR -c $CONF_DIR -x"
|
INSTALL_INC="$INSTALLER -b $BOTS_DIR -c $CONF_DIR -x"
|
||||||
}
|
}
|
||||||
|
|
||||||
wget_opts() {
|
|
||||||
local opts=
|
|
||||||
|
|
||||||
# GNU wget / Busybox 1.26.2
|
|
||||||
if wget --help 2>&1 | grep "\--spider" >/dev/null 2>&1; then
|
|
||||||
opts="--spider"
|
|
||||||
else # Busybox wget < 1.26.2
|
|
||||||
opts="-s"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $opts
|
|
||||||
}
|
|
||||||
|
|
||||||
check_online() {
|
check_online() {
|
||||||
local url=$1 options=$(wget_opts)
|
local url=$1
|
||||||
|
local response_code=$(curl -o /dev/null --silent --head --write-out '%{http_code}' $url)
|
||||||
|
|
||||||
if wget $options $url >/dev/null 2>&1; then
|
if [ "$response_code" = "200" ]; then
|
||||||
echo "true"
|
echo "true"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -400,7 +382,7 @@ main() {
|
||||||
printf "Checking url: $include_url\n"
|
printf "Checking url: $include_url\n"
|
||||||
if [ -n "$(check_online $include_url)" ]; then
|
if [ -n "$(check_online $include_url)" ]; then
|
||||||
local tmp=$(mktemp)
|
local tmp=$(mktemp)
|
||||||
wget -q $include_url -O $tmp
|
curl -s -o $tmp $include_url
|
||||||
# use period not source in POSIX shell
|
# use period not source in POSIX shell
|
||||||
. $tmp 2>/dev/null
|
. $tmp 2>/dev/null
|
||||||
rm -f $tmp
|
rm -f $tmp
|
||||||
|
|
Loading…
Add table
Reference in a new issue