#!/bin/bash
CONF_LINK=https://dl.dropboxusercontent.com/u/32823955/scripts/nginx.conf

echo "Installing software"
sudo apt-get update > /dev/null
sudo apt-get -y install nginx cloud-guest-utils > /dev/null

DNS_NAME=$(ec2metadata --public-hostname)

sudo rm /ect/nginx/sites-available/default
sudo rm /ect/nginx/sites-enabled/default
echo "Start configure software"
sudo wget $CONF_LINK -O /etc/nginx/sites-available/$DNS_NAME
sudo sed -i "s/localhost/$DNS_NAME:80/g" /etc/nginx/sites-available/$DNS_NAME
sudo ln -s /etc/nginx/sites-available/$DNS_NAME /etc/nginx/sites-enabled/$DNS_NAME