mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-02 02:29:58 +00:00
setup-ngxblocker: add option to configure all files
* adds an option to find_vhosts() to configure all files in $VHOST_DIR if none are found with an extension of $VHOST_EXT fixes https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/147 further fixes https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/issues/137
This commit is contained in:
parent
59eb8358d1
commit
bdb0fa96bb
1 changed files with 15 additions and 8 deletions
|
@ -79,9 +79,7 @@ update_paths() {
|
||||||
}
|
}
|
||||||
|
|
||||||
check_config() {
|
check_config() {
|
||||||
local files="$*"
|
if [ -z "$FILE_LIST" ]; then
|
||||||
|
|
||||||
if [ -z "$files" ]; then
|
|
||||||
printf "${BOLDGREEN}using a file extension for vhost files allows multiple domains to be included with a single directive in nginx.conf:\n\n"
|
printf "${BOLDGREEN}using a file extension for vhost files allows multiple domains to be included with a single directive in nginx.conf:\n\n"
|
||||||
printf "${BOLDWHITE}include /etc/nginx/sites-enabled/*.vhost;\n\n"
|
printf "${BOLDWHITE}include /etc/nginx/sites-enabled/*.vhost;\n\n"
|
||||||
printf "${BOLDYELLOW}see command line switches below: ${BOLDGREEN}-e ${RESET}to customise the vhost file extension\n\n"
|
printf "${BOLDYELLOW}see command line switches below: ${BOLDGREEN}-e ${RESET}to customise the vhost file extension\n\n"
|
||||||
|
@ -97,7 +95,16 @@ check_config() {
|
||||||
}
|
}
|
||||||
|
|
||||||
find_vhosts() {
|
find_vhosts() {
|
||||||
find $VHOST_DIR -type f -name "*.$VHOST_EXT"
|
local ans=
|
||||||
|
FILE_LIST=$(find $VHOST_DIR -type f -name "*.$VHOST_EXT")
|
||||||
|
|
||||||
|
if [ -z "$FILE_LIST" ]; then
|
||||||
|
find $VHOST_DIR -type f
|
||||||
|
printf "\n${BOLDWHITE}Configure every file above as a vhost ? [Y/N] : "; read ans
|
||||||
|
case "$ans" in
|
||||||
|
y*|Y*) FILE_LIST=$(find $VHOST_DIR -type f);;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
whitelist_ips() {
|
whitelist_ips() {
|
||||||
|
@ -330,7 +337,7 @@ check_online() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local include_url= file= line= file_list= col_size= blacklist=
|
local include_url= file= line= col_size= blacklist=
|
||||||
local CONF_FILES= VHOST_INCLUDES=
|
local CONF_FILES= VHOST_INCLUDES=
|
||||||
local REPO=https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master
|
local REPO=https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master
|
||||||
|
|
||||||
|
@ -345,8 +352,8 @@ main() {
|
||||||
check_depends
|
check_depends
|
||||||
|
|
||||||
# check vhosts
|
# check vhosts
|
||||||
file_list=$(find_vhosts)
|
find_vhosts
|
||||||
check_config $file_list
|
check_config
|
||||||
|
|
||||||
# check repo is online & source includes
|
# check repo is online & source includes
|
||||||
include_url=$REPO/include_filelist.txt
|
include_url=$REPO/include_filelist.txt
|
||||||
|
@ -394,7 +401,7 @@ main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# update vhosts
|
# update vhosts
|
||||||
for file in $file_list; do
|
for file in $FILE_LIST; do
|
||||||
line=$(find_includes $file include last server_ last location first )
|
line=$(find_includes $file include last server_ last location first )
|
||||||
|
|
||||||
if [ -n "$(check_wildcard $file $BOTS_DIR)" ]; then
|
if [ -n "$(check_wildcard $file $BOTS_DIR)" ]; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue