Commit 98f9d2ed authored by Aral Balkan's avatar Aral Balkan
Browse files

Initial add.

parents
[user]
name = {GIT_ACCOUNT_NAME}
email = {GIT_ACCOUNT_EMAIL}
#!/bin/bash
read oldrev newrev ref
if [ $ref != "refs/heads/master" ]; then
echo "[INFO] No changes, not updating the site."
exit 0
fi
# Courtesy of: http://gitolite.com/deploy.html
echo "[INFO] Fetching latest changes…"
cd /home/git/site/
unset GIT_DIR
git fetch origin
git reset --hard origin/master
echo "[INFO] Updated site content."
#!/bin/bash
################################################################################
#
# Sets up the Better Web Site.
#
# For Ubuntu 14.04. Not designed for/tested on any other operating system.
#
# Prerequisites:
#
# Requires a server with git. You will need git
# to clone this repo so this should not be an unexpected requirement:
#
# sudo apt-get update
# sudo apt-get install git
#
# Usage:
#
# ./install
#
################################################################################
# Abort on errors.
set -e
# ANSI character codes
ansiBoldStart='\033[1m'
ansiBoldEnd='\033[22m'
ansiForegroundBlack='\033[30m'
ansiForegroundDefault='\033[39m'
ansiBackgroundBlue='\033[44m'
ansiBackgroundYellow='\033[43m'
ansiBackgroundDefault='\033[49m'
echo -e "\n────────────────────────────────────────────────────────────────────────────────"
echo -e "${ansiBackgroundBlue}${ansiForegroundBlack} Better Web Site Server Setup ${ansiBackgroundDefault}${ansiForegroundDefault}"
echo -e "────────────────────────────────────────────────────────────────────────────────\n"
# Check for commandline arguments.
# -s: Use Let’s Encrypt *staging server*. Useful when testing the
# deployment script so that we don’t hit the rate limits.
letsEncryptServer='default'
letsEncryptServerURL='https:\/\/acme-v01.api.letsencrypt.org\/directory' # default: live
curlSecurity=''
while getopts ":s" opt; do
case $opt in
s)
# Set the server URL to use the staging server.
letsEncryptServer='staging'
letsEncryptServerURL='https:\/\/acme-staging.api.letsencrypt.org\/directory'
curlSecurity='--insecure'
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
echo -e " ┌────────────────────────────────────────┐"
echo -e " │ Using Let’s Encrypt ${ansiBoldStart}${letsEncryptServer}${ansiBoldEnd} server. │"
echo -e " └────────────────────────────────────────┘\n"
#
# Configuration options.
#
echo -e "1. Configuration options (all defaults are for better.fyi).\n"
#
# Prompt for configuration (With defaults set for better.fyi.)
# Note: defaults are Bash 3-compatible on purpose.
#
# The server names
#
# In your DNS configuration, create an A record (IP address) for www.better.fyi
# and an alias (A record; IP address) to point to www.better.fyi.
#
read -e -p " Server names (better.fyi www.better.fyi): " serverNames
serverNames=${serverNames:-better.fyi www.better.fyi}
# Git account name to use in ~/.gitconfig
read -e -p " Git account name (Better): " gitAccountName
serverNames=${serverNames:-better.fyi www.better.fyi}
# Git account email to use in ~/.gitconfig
read -e -p " Git account email (hello+better+site@ind.ie): " serverNames
serverNames=${serverNames:-better.fyi www.better.fyi}
#
# HTTP server
#
# Handles the Let’s Encrypt verification challenge.
server {
listen 80;
server_name {SERVER_NAMES};
location '/.well-known/acme-challenge' {
default_type "text/plain";
alias /var/www/letsencrypt;
}
location / {
return 301 https://$server_name$request_uri;
}
}
#
# Better.fyi Web Site. (HTTPS server.)
#
server {
listen 443;
server_name {SERVER_NAMES};
ssl on;
ssl_certificate /srv/letsencrypt/certs/better.fyi/fullchain.pem;
ssl_certificate_key /srv/letsencrypt/certs/better.fyi/privkey.pem;
# Serve the site from the git repository.
root /home/git/site/;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location = /apple-app-site-association {
# The Apple App Site Association file must be served with the
# application/pkcs7-mime type.
# (See http://blog.tapstream.com/ios9-search-universal-links/ and
# validate via https://limitless-sierra-4673.herokuapp.com)
default_type application/pkcs7-mime;
}
# Deny access to hidden files (including the .git folder)
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
#error_page 404 /404.html;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment