mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-02 10:40:36 +00:00
commit
5d2c143e0f
3 changed files with 20 additions and 4 deletions
|
@ -141,6 +141,16 @@ download_files() {
|
||||||
fi
|
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() {
|
check_config() {
|
||||||
local x= dirs="$*"
|
local x= dirs="$*"
|
||||||
|
|
||||||
|
@ -283,6 +293,11 @@ main() {
|
||||||
download_files conf.d $CONF_DIR $CONF_FILES
|
download_files conf.d $CONF_DIR $CONF_FILES
|
||||||
download_files bots.d $BOTS_DIR $BOT_FILES
|
download_files bots.d $BOTS_DIR $BOT_FILES
|
||||||
download_files / $SCRIPT_DIR $SCRIPT_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 ##
|
## START ##
|
||||||
|
|
|
@ -186,8 +186,9 @@ find_line() {
|
||||||
local file=$1 find_str=$2 first_last=$3
|
local file=$1 find_str=$2 first_last=$3
|
||||||
|
|
||||||
case "$first_last" in
|
case "$first_last" in
|
||||||
first) awk "/$find_str/{ print NR; exit }" $file;;
|
# ignore file #comments
|
||||||
last) awk "/$find_str/{ print NR }" $file | tail -n1;;
|
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
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,8 +194,8 @@ check_args() {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_mail_depends() {
|
check_mail_depends() {
|
||||||
if [ ! -f /usr/bin/mail ]; then # mailx + ssmtp are enough to send emails
|
if [ ! -f /usr/bin/mail ] && [ ! -f /bin/mail ]; then # mailx + ssmtp are enough to send emails
|
||||||
printf "${BOLDYELLOW}WARN${RESET}: missing /usr/bin/mail => ${BOLDWHITE}disabling emails${RESET}.\n\n"
|
printf "${BOLDYELLOW}WARN${RESET}: missing mail command => ${BOLDWHITE}disabling emails${RESET}.\n\n"
|
||||||
SEND_EMAIL="N"
|
SEND_EMAIL="N"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue