[GHA] Add install-nginx-1.sh

This commit is contained in:
Mitchell Krog 2021-06-21 12:41:23 +02:00
parent 6405ca19ee
commit a69095445a
No known key found for this signature in database
GPG key ID: E02E9D10427B6A43
2 changed files with 33 additions and 28 deletions

View file

@ -36,3 +36,4 @@ jobs:
echo "export TERM=xterm" >> ~/.bashrc
source ~/.bashrc
./dev-tools/generate-files.sh
./dev-tools/install-nginx-1.sh

View file

@ -16,6 +16,10 @@
# #
##############################################################################
set -e
set -o pipefail
export TERM=xterm
# ------------------------------------------------------------------------------
# MIT License
# ------------------------------------------------------------------------------
@ -80,7 +84,7 @@ printf "\n"
echo "${bold}${yellow}---------------------------"
echo "${bold}${yellow}Making backup of nginx.conf"
echo "${bold}${yellow}---------------------------"
sudo cp /etc/nginx/nginx.conf ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_backup_nginxconf/nginx.conf
sudo cp ./etc/nginx/nginx.conf ./dev-tools/test1_conf_backup_nginxconf/nginx.conf
}
prepareVhost () {
@ -88,22 +92,22 @@ printf "\n"
echo "${bold}${yellow}-------------------------------------------"
echo "${bold}${yellow}Delete any default files installed by Nginx"
echo "${bold}${yellow}-------------------------------------------"
sudo rm /etc/nginx/sites-available/*
sudo rm /etc/nginx/sites-enabled/*
sudo rm /var/www/html/*
sudo rm ./etc/nginx/sites-available/*
sudo rm ./etc/nginx/sites-enabled/*
sudo rm ./var/www/html/*
printf "\n"
echo "${bold}${yellow}---------------------"
echo "${bold}${yellow}Setup Vhost for Nginx"
echo "${bold}${yellow}---------------------"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/default.vhost /etc/nginx/sites-available/default.vhost
sudo ln -s /etc/nginx/sites-available/default.vhost /etc/nginx/sites-enabled/default.vhost
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/index.html /var/www/html/index.html
sudo cp ./dev-tools/default.vhost /etc/nginx/sites-available/default.vhost
sudo ln -s ./etc/nginx/sites-available/default.vhost /etc/nginx/sites-enabled/default.vhost
sudo cp ./dev-tools/index.html /var/www/html/index.html
}
makeScriptsExecutable () {
sudo chmod +x /usr/sbin/install-ngxblocker
sudo chmod +x /usr/sbin/setup-ngxblocker
sudo chmod +x /usr/sbin/update-ngxblocker
sudo chmod +x ./usr/sbin/install-ngxblocker
sudo chmod +x ./usr/sbin/setup-ngxblocker
sudo chmod +x ./usr/sbin/update-ngxblocker
}
getinstallngxblocker () {
@ -111,8 +115,8 @@ printf "\n"
echo "${bold}${magenta}--------------------------------------"
echo "${bold}${magenta}Fetch install-ngxblocker from the repo"
echo "${bold}${magenta}--------------------------------------"
sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/install-ngxblocker -O /usr/sbin/install-ngxblocker
sudo chmod +x /usr/sbin/install-ngxblocker
sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/install-ngxblocker -O ./usr/sbin/install-ngxblocker
sudo chmod +x ./usr/sbin/install-ngxblocker
}
runinstallngxblocker () {
@ -120,7 +124,7 @@ echo "${bold}${magenta}--------------------------"
echo "${bold}${magenta}Execute install-ngxblocker"
echo "${bold}${magenta}--------------------------"
cd /usr/sbin
sudo bash ./install-ngxblocker -s /usr/sbin/ -x
sudo bash ./install-ngxblocker -s ./usr/sbin/ -x
}
runsetupngxblocker1 () {
@ -129,7 +133,7 @@ echo "${bold}${magenta}------------------------"
echo "${bold}${magenta}Execute setup-ngxblocker"
echo "${bold}${magenta}------------------------"
cd /usr/sbin
sudo bash ./setup-ngxblocker -i /usr/sbin/install-ngxblocker -x
sudo bash ./setup-ngxblocker -i ./usr/sbin/install-ngxblocker -x
}
runsetupngxblocker2 () {
@ -142,7 +146,7 @@ sudo bash ./setup-ngxblocker -x
}
loadNginxConf () {
sudo nginx -c /etc/nginx/nginx.conf
sudo nginx -c ./etc/nginx/nginx.conf
}
forceUpdateTest1 () {
@ -150,17 +154,17 @@ printf "\n"
echo "${bold}${yellow}----------------------------------------------------"
echo "${bold}${yellow}Copy older globalblacklist.conf file to force update"
echo "${bold}${yellow}----------------------------------------------------"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/globalblacklist-dummy.conf /etc/nginx/conf.d/globalblacklist.conf
sudo cp ./dev-tools/globalblacklist-dummy.conf ./etc/nginx/conf.d/globalblacklist.conf
}
forceUpdateTest2 () {
echo "${bold}${yellow}--------------------------------------"
echo "${bold}${yellow}Delete Files to test update-ngxblocker"
echo "${bold}${yellow}--------------------------------------"
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/
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/
}
forceUpdateTest3 () {
@ -168,7 +172,7 @@ printf "\n"
echo "${bold}${yellow}----------------------------------------------------"
echo "${bold}${yellow}Copy older globalblacklist.conf file to force update"
echo "${bold}${yellow}----------------------------------------------------"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/globalblacklist-dummy.conf /etc/nginx/conf.d/globalblacklist.conf
sudo cp ./dev-tools/globalblacklist-dummy.conf ./etc/nginx/conf.d/globalblacklist.conf
}
runupdatengxblocker () {
@ -184,7 +188,7 @@ activateLatestBlacklist () {
echo "${bold}${yellow}------------------------------------------------------------"
echo "${bold}${yellow}Make sure we test with latest generated globalblacklist.conf"
echo "${bold}${yellow}------------------------------------------------------------"
sudo cp ${TRAVIS_BUILD_DIR}/conf.d/globalblacklist.conf /etc/nginx/conf.d/globalblacklist.conf
sudo cp ./conf.d/globalblacklist.conf ./etc/nginx/conf.d/globalblacklist.conf
}
backupConfFiles () {
@ -192,10 +196,10 @@ printf "\n"
echo "${bold}${green}-------------------------------------------------------"
echo "${bold}${green}Backup all conf files and folders used during this test"
echo "${bold}${green}-------------------------------------------------------"
sudo cp /etc/nginx/bots.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files/bots.d/
sudo cp /etc/nginx/conf.d/* ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files/conf.d/
sudo cp /etc/nginx/sites-available/default.vhost ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files/default.vhost
sudo cp /etc/nginx/nginx.conf ${TRAVIS_BUILD_DIR}/.dev-tools/test1_conf_files/nginx.conf
sudo cp ./etc/nginx/bots.d/* ./dev-tools/test1_conf_files/bots.d/
sudo cp ./etc/nginx/conf.d/* ./dev-tools/test1_conf_files/conf.d/
sudo cp ./etc/nginx/sites-available/default.vhost ./dev-tools/test1_conf_files/default.vhost
sudo cp ./etc/nginx/nginx.conf ./dev-tools/test1_conf_files/nginx.conf
}
copyNginxConf () {
@ -203,11 +207,11 @@ printf "\n"
echo "${bold}${magenta}------------------------------"
echo "${bold}${magenta}Copy nginx.conf to /etc/nginx/"
echo "${bold}${magenta}------------------------------"
sudo cp ${TRAVIS_BUILD_DIR}/.dev-tools/test_units/nginx.conf-newformat /etc/nginx/nginx.conf
sudo cp ./dev-tools/test_units/nginx.conf-newformat ./etc/nginx/nginx.conf
}
getnginxversion () {
sudo nginx -v &> ${TRAVIS_BUILD_DIR}/.dev-tools/nginxv1.txt
sudo nginx -v &> ./dev-tools/nginxv1.txt
}
# ------------------