From 54ea291834d05f48fe3057045a75e7f657cae1ae Mon Sep 17 00:00:00 2001 From: Stuart Cardall Date: Tue, 19 Sep 2017 22:12:56 +0000 Subject: [PATCH 1/3] setup-ngxblocker: improve find_line() detection * adds regex to ignore commented lines in vhost files --- setup-ngxblocker | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup-ngxblocker b/setup-ngxblocker index c84e5527f..30f24d79a 100755 --- a/setup-ngxblocker +++ b/setup-ngxblocker @@ -186,8 +186,9 @@ find_line() { local file=$1 find_str=$2 first_last=$3 case "$first_last" in - first) awk "/$find_str/{ print NR; exit }" $file;; - last) awk "/$find_str/{ print NR }" $file | tail -n1;; + # ignore file #comments + first) grep -nE "^[ ]+$find_str" $file | head -n1 | awk -F: '{print $1}' + last) grep -nE "^[ ]+$find_str" $file | tail -n1 | awk -F: '{print $1}' esac } From 26d03bd7f14911ee567e7714efaaa44e29916271 Mon Sep 17 00:00:00 2001 From: Stuart Cardall Date: Tue, 19 Sep 2017 22:14:42 +0000 Subject: [PATCH 2/3] install-ngxblocker: add set_mode() * ensures all $SCRIPT_FILES are executable --- install-ngxblocker | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/install-ngxblocker b/install-ngxblocker index 4ebb34a12..2ca0f621c 100755 --- a/install-ngxblocker +++ b/install-ngxblocker @@ -141,6 +141,16 @@ download_files() { fi } +set_mode() { + local mode=$1 dir=$2 file= + local file_list="$(echo $@ | awk '{$1=$2=""; print}' | sed -e 's/^[ \t]*//')" + + for file in $file_list; do + printf "Setting mode: $mode => $dir/$file\n" + chmod $mode $dir/$file + done +} + check_config() { local x= dirs="$*" @@ -283,6 +293,11 @@ main() { download_files conf.d $CONF_DIR $CONF_FILES download_files bots.d $BOTS_DIR $BOT_FILES download_files / $SCRIPT_DIR $SCRIPT_FILES + + # ensures scripts are executable + if [ "$DRY_RUN" = "N" ]; then + set_mode 700 $SCRIPT_DIR $SCRIPT_FILES + fi } ## START ## From 6af2dc7f92699cb216d25fdd55d3442adadf79ad Mon Sep 17 00:00:00 2001 From: Stuart Cardall Date: Tue, 19 Sep 2017 22:31:54 +0000 Subject: [PATCH 3/3] update-ngxblocker: detect /bin/mail in centos * also detect /bin/mail in centos closes https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/97 --- update-ngxblocker | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update-ngxblocker b/update-ngxblocker index 186a513d7..b3869e5da 100755 --- a/update-ngxblocker +++ b/update-ngxblocker @@ -194,8 +194,8 @@ check_args() { } check_mail_depends() { - if [ ! -f /usr/bin/mail ]; then # mailx + ssmtp are enough to send emails - printf "${BOLDYELLOW}WARN${RESET}: missing /usr/bin/mail => ${BOLDWHITE}disabling emails${RESET}.\n\n" + if [ ! -f /usr/bin/mail ] && [ ! -f /bin/mail ]; then # mailx + ssmtp are enough to send emails + printf "${BOLDYELLOW}WARN${RESET}: missing mail command => ${BOLDWHITE}disabling emails${RESET}.\n\n" SEND_EMAIL="N" fi }