From 26fec015ed5922dc14144532018cd3c5505cc6fa Mon Sep 17 00:00:00 2001 From: Stuart Cardall Date: Wed, 23 Aug 2017 22:13:32 +0000 Subject: [PATCH 1/2] update-ngxblocker: fix dash shell incompatibility closes https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/75 * dash shell need $@ to be quoted * SCRIPT_DIR is checked by install-ngxblocker so not passed to check_dirs() --- update-ngxblocker | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update-ngxblocker b/update-ngxblocker index fb2b819c2..4566ea6e0 100755 --- a/update-ngxblocker +++ b/update-ngxblocker @@ -104,7 +104,7 @@ check_version() { } check_dirs() { - local x= dirs=$@ + local x= dirs="$@" for x in $dirs; do if [ ! -d $x ]; then @@ -274,10 +274,10 @@ main() { fi check_depends - check_dirs $BOTS_DIR $CONF_DIR $SCRIPT_DIR # parse command line get_options $@ + check_dirs $BOTS_DIR $CONF_DIR url=$REPO/$remote_dir/$file output=$CONF_DIR/$file From c62ef4f008dfa0b61b035490c68246a78fcc89e4 Mon Sep 17 00:00:00 2001 From: Stuart Cardall Date: Wed, 23 Aug 2017 22:51:14 +0000 Subject: [PATCH 2/2] update-ngxblocker: use curl not wget * make downloads more robust & informative with curl --- update-ngxblocker | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/update-ngxblocker b/update-ngxblocker index 4566ea6e0..4d926a426 100755 --- a/update-ngxblocker +++ b/update-ngxblocker @@ -263,7 +263,7 @@ get_options() { main() { local REPO=https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master - local file=globalblacklist.conf remote_dir=conf.d url= output= update= status= + local file=globalblacklist.conf remote_dir=conf.d url= output= update= status= tmp= # default to service (centos does not have 'which' by default) local service=${service_cmd:-"service"} @@ -288,8 +288,18 @@ main() { if echo $update | grep ^Update 1>/dev/null; then # download globalblacklist update + tmp=$(mktemp) mkdir -p $CONF_DIR - wget $url $(wget_opts) -O $output 2>&1 + printf "${BOLDWHITE}Downloading: $file " + curl --fail --connect-timeout 60 --retry 10 --retry-delay 5 -so $tmp $url + + case "$?" in + 0) printf "...${BOLDGREEN}OK${RESET}\n\n" + mv $tmp $output + ;; + 22) printf "...${BOLDRED}ERROR 404: $url${RESET}\n\n";; + 28) printf "...${BOLDRED}ERROR TIMEOUT: $url${RESET}\n\n";; + esac # download new bots.d / conf.d files $INSTALL_INC