Skip to content

Commit

Permalink
final cleanup of repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellkrogza committed May 4, 2017
1 parent adf91ff commit 523f373
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 218 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ install:
- sudo apt-get update
- sudo apt-get install -y --force-yes nginx-extras
script:
- travis-ci/install-nginx2.sh
- travis-ci/install-nginx.sh
- curl -vsf 'http://localhost:9000/index.php' &> /dev/stdout
- curl -A "googlebot" http://localhost:9000/index.php &> /dev/stdout
- STATUSCODE=$(curl -A "80legs" http://localhost:9000/index.php &> /dev/stderr --write-out "%{http_code}") | if test $STATUSCODE 52; then exit 0; fi
- STATUSCODE=$(curl -A "masscan" http://localhost:9000/index.php &> /dev/stderr --write-out "%{http_code}") | if test $STATUSCODE 52; then exit 0; fi
- STATUSCODE=$(curl -I http://localhost:9000/index.php -e http://100dollars-seo.com &> /dev/stderr --write-out "%{http_code}") | if test $STATUSCODE 52; then exit 0; fi
- STATUSCODE=$(curl -I http://localhost:9000/index.php -e http://zx6.ru &> /dev/stderr --write-out "%{http_code}") | if test $STATUSCODE 52; then exit 0; fi
- travis-ci/changefile.sh
- travis-ci/change-file.sh

before_deploy:
- travis-ci/deploy2.sh
- travis-ci/deploy-package.sh
deploy:
provider: releases
api_key:
Expand Down
15 changes: 0 additions & 15 deletions travis-ci/before-deploy.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
38 changes: 0 additions & 38 deletions travis-ci/deploy.sh

This file was deleted.

33 changes: 0 additions & 33 deletions travis-ci/fastcgi.tpl

This file was deleted.

File renamed without changes.
113 changes: 59 additions & 54 deletions travis-ci/install-nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,64 @@
# Travis CI Bash Script for Installing Nginx on Travis CI and Testing Configurations
# https://github.com/mitchellkrogza

set -e
set -x

DIR=$(realpath $(dirname "$0"))
USER=$(whoami)
PHP_VERSION=$(phpenv version-name)
ROOT=$(realpath "$DIR/..")
PORT=9000
SERVER="/tmp/php.sock"

function tpl {
sed \
-e "s|{DIR}|$DIR|g" \
-e "s|{USER}|$USER|g" \
-e "s|{PHP_VERSION}|$PHP_VERSION|g" \
-e "s|{ROOT}|$ROOT|g" \
-e "s|{PORT}|$PORT|g" \
-e "s|{SERVER}|$SERVER|g" \
< $1 > $2
}

# Make some working directories.
mkdir "$DIR/nginx"
mkdir "$DIR/nginx/sites-enabled"
mkdir "$DIR/var"

# Configure the PHP handler.
if [ "$PHP_VERSION" = 'hhvm' ] || [ "$PHP_VERSION" = 'hhvm-nightly' ]
then
HHVM_CONF="$DIR/nginx/hhvm.ini"

tpl "$DIR/hhvm.tpl" "$HHVM_CONF"

cat "$HHVM_CONF"

hhvm \
--mode=daemon \
--config="$HHVM_CONF"
else
PHP_FPM_BIN="$HOME/.phpenv/versions/$PHP_VERSION/sbin/php-fpm"
PHP_FPM_CONF="$DIR/nginx/php-fpm.conf"

# Build the php-fpm.conf.
tpl "$DIR/php-fpm.tpl" "$PHP_FPM_CONF"

# Start php-fpm
"$PHP_FPM_BIN" --fpm-config "$PHP_FPM_CONF"
fi

# Build the default nginx config files.
tpl "$DIR/nginx.tpl" "$DIR/nginx/nginx.conf"
tpl "$DIR/fastcgi.tpl" "$DIR/nginx/fastcgi.conf"
tpl "$DIR/defaultsite.tpl" "$DIR/nginx/sites-enabled/defaultsite.conf"

# Start nginx.
nginx -c "$DIR/nginx/nginx.conf"
# 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/www/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
66 changes: 0 additions & 66 deletions travis-ci/install-nginx2.sh

This file was deleted.

9 changes: 0 additions & 9 deletions travis-ci/php-fpm.tpl

This file was deleted.

0 comments on commit 523f373

Please sign in to comment.