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)
[ -n ] : NO whitelist of .names only (default: $DOT_NAMES)
[ -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)
[ -h ] : this help message
@ -100,7 +101,8 @@ find_vhosts() {
local ans=
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
printf "\n${BOLDWHITE}Configure every file above as a vhost ? [Y/N] : "; read ans
case "$ans" in
@ -331,7 +333,7 @@ check_nginx_directives() {
get_options() {
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
if [ -n "${OPTARG}" ]; then
case "$opts" in
@ -352,6 +354,7 @@ get_options() {
n) DOT_NAMES=N ;;
d) INC_DDOS=N ;;
x) DRY_RUN=N ;;
z) SETUP_VHOST=N ;;
h) usage ;;
\?) usage ;;
:) check_args $OPTARG none none ;;