22# Travis CI Bash Script for Installing Nginx on Travis CI and Testing Configurations
33# https://github.com/mitchellkrogza
44
5- # set -e
65set -x
7- # set -v
8-
9- # DIR=$(realpath $(dirname "$0"))
10- # USER=$(whoami)
11- # PHP_VERSION=$(phpenv version-name)
12- # ROOT=$(realpath "$DIR/..")
13- # PORT=9000
14- # SERVER="/tmp/php.sock"
15-
16- # function tpl {
17- # sed \
18- # -e "s|{DIR}|$DIR|g" \
19- # -e "s|{USER}|$USER|g" \
20- # -e "s|{PHP_VERSION}|$PHP_VERSION|g" \
21- # -e "s|{ROOT}|$ROOT|g" \
22- # -e "s|{PORT}|$PORT|g" \
23- # -e "s|{SERVER}|$SERVER|g" \
24- # < $1 > $2
25- # }
26-
27- # Make some working directories.
28- # mkdir "$DIR/nginx"
29- # mkdir "$DIR/nginx/sites-enabled"
30- # mkdir "$DIR/var"
31-
32- # Configure the PHP handler.
33- # if [ "$PHP_VERSION" = 'hhvm' ] || [ "$PHP_VERSION" = 'hhvm-nightly' ]
34- # then
35- # HHVM_CONF="$DIR/nginx/hhvm.ini"
36-
37- # tpl "$DIR/hhvm.tpl" "$HHVM_CONF"
38-
39- # cat "$HHVM_CONF"
40-
41- # hhvm \
42- # --mode=daemon \
43- # --config="$HHVM_CONF"
44- # else
45- # PHP_FPM_BIN="$HOME/.phpenv/versions/$PHP_VERSION/sbin/php-fpm"
46- # PHP_FPM_CONF="$DIR/nginx/php-fpm.conf"
47-
48- # Build the php-fpm.conf.
49- # tpl "$DIR/php-fpm.tpl" "$PHP_FPM_CONF"
50-
51- # Start php-fpm
52- # "$PHP_FPM_BIN" --fpm-config "$PHP_FPM_CONF"
53- # fi
54-
55- # Build the default nginx config files.
56- # tpl "$DIR/nginx.tpl" "$DIR/nginx/nginx.conf"
57- # tpl "$DIR/fastcgi.tpl" "$DIR/nginx/fastcgi.conf"
58- # tpl "$DIR/defaultsite.tpl" "$DIR/nginx/sites-enabled/defaultsite.conf"
59-
60- # Start nginx.
61- # nginx -c "$DIR/nginx/nginx.conf"
62- # echo $TRAVIS_BUILD_DIR
63- # Check Date
64- date
6+
7+ # Check Date - I only used this for testing to make sure I had set timezone correctly
8+ # See .travis.yml file in the before_install section on how to set your timezone on TravisCI
9+ # date
10+
11+ # Start Getting Nginx Ready for Testing the Nginx Bad Bot Blocker
12+
13+ # Delete default site created by Nginx Installation
6514sudo rm /etc/nginx/sites-available/default
15+
16+ # Download the Nginx Bad Bot Blocker files from the Live Repository
6617sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/install-ngxblocker -O /usr/sbin/install-ngxblocker
6718sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/setup-ngxblocker -O /usr/sbin/setup-ngxblocker
6819sudo wget https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/update-ngxblocker -O /usr/sbin/update-ngxblocker
20+
21+ # Set our install and setup scripts to be executable
6922sudo chmod +x /usr/sbin/install-ngxblocker
7023sudo chmod +x /usr/sbin/setup-ngxblocker
7124sudo chmod +x /usr/sbin/update-ngxblocker
25+
26+ # Run Install-NgxBlocker
7227cd /usr/sbin
7328sudo ./install-ngxblocker -x
29+
30+ # Copy our default.vhost file into Nginx /sites-available/
7431sudo cp $TRAVIS_BUILD_DIR /travis-ci/default.vhost /etc/nginx/sites-available/default.vhost
32+
33+ # Link the vhost file into Nginx /sites-enabled/ and reload nginx
7534sudo ln -s /etc/nginx/sites-available/default.vhost /etc/nginx/sites-enabled/default.vhost
35+ sudo service nginx reload
36+
37+ # Run setup-ngxblocker
7638cd /usr/sbin
77- # Below for Verbose Testing of setup-ngxblocker
78- # sudo sh -x ./setup-ngxblocker -x
7939sudo ./setup-ngxblocker -x
40+
41+ # NOTE: for Verbose Testing of any shell scripts use below format adding sh -x before running the script
42+ # this helps a lot inside the TravisCI environment to see where a shell script may be failing
43+ # sudo sh -x ./setup-ngxblocker -x
44+
45+ # Load our Nginx.conf file and reload Nginx
8046sudo nginx -c /etc/nginx/nginx.conf
8147sudo service nginx reload
82- # sudo nginx -t &> /dev/stdout
83- # cat /etc/nginx/nginx.conf
84- # sudo nginx -V
85- # sudo netstat -peanut
48+
49+ # Copy our index.php file into the default site's root folder
8650sudo cp $TRAVIS_BUILD_DIR /www/index.php /var/www/html/index.php
51+
52+ # Run update-ngxblocker test
8753cd /usr/sbin
8854sudo ./update-ngxblocker
55+
56+ # Reload nginx
8957sudo service nginx reload
58+
59+ # Set all our other setup and deploy scripts to be executable
9060sudo chmod +x $TRAVIS_BUILD_DIR /travis-ci/modify-globalblacklist.sh
9161sudo chmod +x $TRAVIS_BUILD_DIR /travis-ci/deploy.sh
9262sudo chmod +x $TRAVIS_BUILD_DIR /travis-ci/before-deploy.sh
9363sudo chmod +x $TRAVIS_BUILD_DIR /travis-ci/deploy2.sh
9464sudo chmod +x $TRAVIS_BUILD_DIR /travis-ci/changefile.sh
95- # sudo $TRAVIS_BUILD_DIR/travis-ci/modify-globalblacklist.sh
96- # cd $TRAVIS_BUILD_DIR
97- # sudo git remote -v
98- # sudo git remote rm origin
99- # cat $TRAVIS_BUILD_DIR/globalblacklist.conf
100- # sudo git config --global user.email "${GIT_EMAIL}"
101- # sudo git config --global user.name "${GIT_NAME}"
102- # sudo git config --global push.default simple
103- # sudo export GIT_TAG=v1.0.$TRAVIS_BUILD_NUMBER
104- # msg="Build $TRAVIS_BUILD_NUMBER"
105- # echo "$msg" >> $TRAVIS_BUILD_DIR/build.txt
106- # sudo git add $TRAVIS_BUILD_DIR/globalblacklist.conf
107- # sudo git commit -m "Build $TRAVIS_BUILD_NUMBER"
108-
109- # sudo sed --version
110- # sudo apt-cache policy dash
65+
66+ # Travis now goes into the rest of the tests in the script: section of .travis.yml
0 commit comments