#!/bin/bash

USER='wikiuser'
DBNAME='mediawiki'
DB_SERVER=$2
PASS='0305'
DNS_NAME=$(ec2metadata --public-hostname)

echo "=============================="
echo $1
echo $2
echo $3

echo 'Installing mediawiki'

cd /var/www/html && sudo php maintenance/install.php --server="http://$DNS_NAME" --dbuser=$USER --dbpass=$PASS --dbname=$DBNAME --dbserver=$DB_SERVER --pass=$PASS --scriptpath="" Test user1

sudo sed -i "s/localhost/$DNS_NAME/g" /etc/nginx/sites-available/$DNS_NAME

sudo service php5-fpm restart 
sudo service nginx restart
