-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-nginx.sh
executable file
·65 lines (48 loc) · 2.62 KB
/
install-nginx.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Travis CI Bash Script for Installing Nginx on Travis CI and Testing Configurations
# https://github.com/mitchellkrogza
set -x
# Check Date - I only used this for testing to make sure I had set timezone correctly
# See .travis.yml file in the before_install section on how to set your timezone on TravisCI
#date
# Start Getting Nginx Ready for Testing the Nginx Bad Bot Blocker
# Delete default site created by Nginx Installation
sudo rm /etc/nginx/sites-available/default
# Download the Nginx Bad Bot Blocker files from the Live Repository
sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/install-ngxblocker -O /usr/sbin/install-ngxblocker
sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/setup-ngxblocker -O /usr/sbin/setup-ngxblocker
sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/update-ngxblocker -O /usr/sbin/update-ngxblocker
# Set our install and setup scripts to be executable
sudo chmod +x /usr/sbin/install-ngxblocker
sudo chmod +x /usr/sbin/setup-ngxblocker
sudo chmod +x /usr/sbin/update-ngxblocker
# Run Install-NgxBlocker
cd /usr/sbin
sudo ./install-ngxblocker -x
# Copy our default.vhost file into Nginx /sites-available/
sudo cp $TRAVIS_BUILD_DIR/travis-ci/default.vhost /etc/nginx/sites-available/default.vhost
# Link the vhost file into Nginx /sites-enabled/ and reload nginx
sudo ln -s /etc/nginx/sites-available/default.vhost /etc/nginx/sites-enabled/default.vhost
#sudo service nginx reload
# Run setup-ngxblocker
cd /usr/sbin
sudo ./setup-ngxblocker -x
# NOTE: for Verbose Testing of any shell scripts use below format adding sh -x before running the script
# this helps a lot inside the TravisCI environment to see where a shell script may be failing
#sudo sh -x ./setup-ngxblocker -x
# Load our Nginx.conf file and reload Nginx
sudo nginx -c /etc/nginx/nginx.conf
#sudo service nginx reload
# Copy our index.php file into the default site's root folder
sudo cp $TRAVIS_BUILD_DIR/travis-ci/index.php /var/www/html/index.php
# Run update-ngxblocker test
cd /usr/sbin
sudo ./update-ngxblocker
# Reload nginx - no need to do this as update-ngxblocker does this for us
#sudo service nginx reload
# Set all our other setup and deploy scripts to be executable
sudo chmod +x $TRAVIS_BUILD_DIR/travis-ci/modify-globalblacklist.sh
sudo chmod +x $TRAVIS_BUILD_DIR/travis-ci/deploy-package.sh
sudo chmod +x $TRAVIS_BUILD_DIR/travis-ci/deploy-package.sh
sudo chmod +x $TRAVIS_BUILD_DIR/travis-ci/change-file.sh
# Travis now goes into the rest of the tests in the script: section of .travis.yml