add option to disable vhost configuration

* adds -z option to disable configuration in automated environments (e.g ansible)

fixes:

https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/286
This commit is contained in:
Stuart Cardall 2020-01-28 13:41:50 +00:00
parent 1811d264d7
commit e7382c264d
No known key found for this signature in database
GPG key ID: AEB857F1C891D0C6

View file

@ -45,6 +45,7 @@ Usage: $script [OPTIONS]
[ -l ] : Manual whitelist of domain (default: none) [ -l ] : Manual whitelist of domain (default: none)
[ -n ] : NO whitelist of .names only (default: $DOT_NAMES) [ -n ] : NO whitelist of .names only (default: $DOT_NAMES)
[ -d ] : NO insert of DDOS rule (default: $INC_DDOS) [ -d ] : NO insert of DDOS rule (default: $INC_DDOS)
[ -z ] : NO configuration of vhosts (default: configure files in $VHOST_DIR)
[ -x ] : Actually change the files (default: don't change anything) [ -x ] : Actually change the files (default: don't change anything)
[ -h ] : this help message [ -h ] : this help message
@ -100,7 +101,8 @@ find_vhosts() {
local ans= local ans=
FILE_LIST=$(find $VHOST_DIR \( -type f -or -type l \) -name "*.$VHOST_EXT") FILE_LIST=$(find $VHOST_DIR \( -type f -or -type l \) -name "*.$VHOST_EXT")
if [ -z "$FILE_LIST" ]; then # vhost configuration can be disabled with '-z' switch
if [ -z "$FILE_LIST" ] && [ -z "$SETUP_VHOST" ]; then
find $VHOST_DIR -type f find $VHOST_DIR -type f
printf "\n${BOLDWHITE}Configure every file above as a vhost ? [Y/N] : "; read ans printf "\n${BOLDWHITE}Configure every file above as a vhost ? [Y/N] : "; read ans
case "$ans" in case "$ans" in
@ -331,7 +333,7 @@ check_nginx_directives() {
get_options() { get_options() {
local arg= opts= local arg= opts=
while getopts :w:l:e:v:b:c:m:i:ndxh opts "$@" while getopts :w:l:e:v:b:c:m:i:ndxzh opts "$@"
do do
if [ -n "${OPTARG}" ]; then if [ -n "${OPTARG}" ]; then
case "$opts" in case "$opts" in
@ -352,6 +354,7 @@ get_options() {
n) DOT_NAMES=N ;; n) DOT_NAMES=N ;;
d) INC_DDOS=N ;; d) INC_DDOS=N ;;
x) DRY_RUN=N ;; x) DRY_RUN=N ;;
z) SETUP_VHOST=N ;;
h) usage ;; h) usage ;;
\?) usage ;; \?) usage ;;
:) check_args $OPTARG none none ;; :) check_args $OPTARG none none ;;