mirror of
https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker.git
synced 2025-09-05 12:09:57 +00:00
UPDATE Prepare/Install Nginx [TEST]
This commit is contained in:
parent
7b5498455c
commit
2992be1687
1 changed files with 77 additions and 68 deletions
|
@ -16,21 +16,22 @@
|
||||||
# #
|
# #
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# MIT License
|
# MIT License
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2017 Mitchell Krog - mitchellkrog@gmail.com
|
# Copyright (c) 2017 Mitchell Krog - mitchellkrog@gmail.com
|
||||||
# https://github.com/mitchellkrogza
|
# https://github.com/mitchellkrogza
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# in the Software without restriction, including without limitation the rights
|
# in the Software without restriction, including without limitation the rights
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# furnished to do so, subject to the following conditions:
|
# furnished to do so, subject to the following conditions:
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# The above copyright notice and this permission notice shall be included in all
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# copies or substantial portions of the Software.
|
# copies or substantial portions of the Software.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
@ -38,12 +39,11 @@
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Run testing of test version
|
# ------------------------
|
||||||
|
|
||||||
# ************************
|
|
||||||
# Set Terminal Font Colors
|
# Set Terminal Font Colors
|
||||||
# ************************
|
# ------------------------
|
||||||
|
|
||||||
bold=$(tput bold)
|
bold=$(tput bold)
|
||||||
red=$(tput setaf 1)
|
red=$(tput setaf 1)
|
||||||
|
@ -55,62 +55,27 @@ cyan=$(tput setaf 6)
|
||||||
white=$(tput setaf 7)
|
white=$(tput setaf 7)
|
||||||
defaultcolor=$(tput setaf default)
|
defaultcolor=$(tput setaf default)
|
||||||
|
|
||||||
printf "\n"
|
# ---------
|
||||||
echo "${bold}${yellow}-----------------------------------"
|
# FUNCTIONS
|
||||||
echo "${bold}${yellow}Delete Files to force fresh testing"
|
# ---------
|
||||||
echo "${bold}${yellow}-----------------------------------"
|
|
||||||
printf "\n"
|
|
||||||
sudo rm /etc/nginx/conf.d/*.conf
|
|
||||||
sudo rm /etc/nginx/bots.d/*.conf
|
|
||||||
ls -la /etc/nginx/conf.d/
|
|
||||||
ls -la /etc/nginx/bots.d/
|
|
||||||
|
|
||||||
printf "\n"
|
reloadNginX () {
|
||||||
echo "${bold}${magenta}-------------------------"
|
echo "${bold}${green}---------------"
|
||||||
echo "${bold}${magenta}Execute update-ngxblocker"
|
echo "${bold}${green}Reloading Nginx"
|
||||||
echo "${bold}${magenta}-------------------------"
|
echo "${bold}${green}---------------"
|
||||||
printf "\n"
|
printf "\n\n"
|
||||||
cd /usr/sbin
|
|
||||||
sudo bash ./update-ngxblocker -n
|
|
||||||
|
|
||||||
|
|
||||||
# ***********************************************************************
|
|
||||||
# Make sure we test latest generated globalblacklist-testing-version.conf
|
|
||||||
# ***********************************************************************
|
|
||||||
|
|
||||||
printf "\n"
|
|
||||||
echo "${bold}${yellow}---------------------------------------------------"
|
|
||||||
echo "${bold}${yellow}Copy Test Unit of globalblacklist.conf file to test"
|
|
||||||
echo "${bold}${yellow}---------------------------------------------------"
|
|
||||||
printf "\n"
|
|
||||||
|
|
||||||
sudo cp ${TRAVIS_BUILD_DIR}/conf.d/globalblacklist-testing-version.conf /etc/nginx/conf.d/globalblacklist.conf
|
|
||||||
|
|
||||||
# *********************
|
|
||||||
# Force reload of Nginx
|
|
||||||
# *********************
|
|
||||||
|
|
||||||
printf "\n"
|
|
||||||
echo "${bold}${green}------------"
|
|
||||||
echo "${bold}${green}Reload Nginx"
|
|
||||||
echo "${bold}${green}------------"
|
|
||||||
printf "\n"
|
|
||||||
sudo nginx -t && sudo nginx -s reload
|
sudo nginx -t && sudo nginx -s reload
|
||||||
|
}
|
||||||
|
|
||||||
# **********************
|
waitforReload () {
|
||||||
# Now Run our Curl Tests
|
echo "${bold}${yellow}-----------------------------------------------------------------------"
|
||||||
# **********************
|
echo "${bold}${yellow}Sleeping for 10 seconds to allow Nginx to Properly Reload inside Travis"
|
||||||
|
echo "${bold}${yellow}-----------------------------------------------------------------------"
|
||||||
printf "\n"
|
printf "\n\n"
|
||||||
echo "${bold}${green}---------------------------"
|
sleep 10s
|
||||||
echo "${bold}${green}Run Bot and Referrer Checks"
|
}
|
||||||
echo "${bold}${green}---------------------------"
|
|
||||||
printf "\n"
|
|
||||||
|
|
||||||
# *************************************************************
|
|
||||||
# Copy all .conf files used in Testing to a folder for checking
|
|
||||||
# *************************************************************
|
|
||||||
|
|
||||||
|
backupConfFiles () {
|
||||||
printf "\n"
|
printf "\n"
|
||||||
echo "${bold}${green}------------------------------------------------------------"
|
echo "${bold}${green}------------------------------------------------------------"
|
||||||
echo "${bold}${green}Make Backup all conf files and folders used during this test"
|
echo "${bold}${green}Make Backup all conf files and folders used during this test"
|
||||||
|
@ -120,29 +85,72 @@ sudo cp /etc/nginx/bots.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/_conf_files_testing_c
|
||||||
sudo cp /etc/nginx/conf.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/_conf_files_testing_changes/conf.d/
|
sudo cp /etc/nginx/conf.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/_conf_files_testing_changes/conf.d/
|
||||||
sudo cp /etc/nginx/sites-available/default.vhost ${TRAVIS_BUILD_DIR}/.dev-tools/_conf_files_testing_changes/default.vhost
|
sudo cp /etc/nginx/sites-available/default.vhost ${TRAVIS_BUILD_DIR}/.dev-tools/_conf_files_testing_changes/default.vhost
|
||||||
sudo cp /etc/nginx/nginx.conf ${TRAVIS_BUILD_DIR}/.dev-tools/_conf_files_testing_changes/nginx.conf
|
sudo cp /etc/nginx/nginx.conf ${TRAVIS_BUILD_DIR}/.dev-tools/_conf_files_testing_changes/nginx.conf
|
||||||
|
}
|
||||||
|
|
||||||
# **********************
|
resetNginx () {
|
||||||
|
printf "\n"
|
||||||
|
echo "${bold}${yellow}-----------------------------------"
|
||||||
|
echo "${bold}${yellow}Delete Files to force fresh testing"
|
||||||
|
echo "${bold}${yellow}-----------------------------------"
|
||||||
|
printf "\n"
|
||||||
|
sudo rm /etc/nginx/conf.d/*.conf
|
||||||
|
sudo rm /etc/nginx/bots.d/*.conf
|
||||||
|
ls -la /etc/nginx/conf.d/
|
||||||
|
ls -la /etc/nginx/bots.d/
|
||||||
|
}
|
||||||
|
|
||||||
|
updateBlocker () {
|
||||||
|
printf "\n"
|
||||||
|
echo "${bold}${magenta}-------------------------"
|
||||||
|
echo "${bold}${magenta}Execute update-ngxblocker"
|
||||||
|
echo "${bold}${magenta}-------------------------"
|
||||||
|
printf "\n"
|
||||||
|
cd /usr/sbin
|
||||||
|
sudo bash ./update-ngxblocker -n
|
||||||
|
}
|
||||||
|
|
||||||
|
copyTestUnit () {
|
||||||
|
printf "\n"
|
||||||
|
echo "${bold}${yellow}---------------------------------------------------"
|
||||||
|
echo "${bold}${yellow}Copy Test Unit of globalblacklist.conf file to test"
|
||||||
|
echo "${bold}${yellow}---------------------------------------------------"
|
||||||
|
printf "\n"
|
||||||
|
sudo cp ${TRAVIS_BUILD_DIR}/conf.d/globalblacklist-testing-version.conf /etc/nginx/conf.d/globalblacklist.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
# -------------
|
||||||
|
# Start Install
|
||||||
|
# -------------
|
||||||
|
|
||||||
|
resetNginx
|
||||||
|
updateBlocker
|
||||||
|
copyTestUnit
|
||||||
|
reloadNginX
|
||||||
|
waitforReload
|
||||||
|
backupConfFiles
|
||||||
|
|
||||||
|
# ----------------------
|
||||||
# Exit With Error Number
|
# Exit With Error Number
|
||||||
# **********************
|
# ----------------------
|
||||||
|
|
||||||
exit ${?}
|
exit ${?}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# MIT License
|
# MIT License
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2017 Mitchell Krog - mitchellkrog@gmail.com
|
# Copyright (c) 2017 Mitchell Krog - mitchellkrog@gmail.com
|
||||||
# https://github.com/mitchellkrogza
|
# https://github.com/mitchellkrogza
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
# in the Software without restriction, including without limitation the rights
|
# in the Software without restriction, including without limitation the rights
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
# furnished to do so, subject to the following conditions:
|
# furnished to do so, subject to the following conditions:
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# The above copyright notice and this permission notice shall be included in all
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
# copies or substantial portions of the Software.
|
# copies or substantial portions of the Software.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
@ -150,3 +158,4 @@ exit ${?}
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
# ------------------------------------------------------------------------------
|
Loading…
Add table
Reference in a new issue