#!/bin/bash
echo $BASH_VERSION
#this script assumes ONLY that you are running this script on a ubuntu/debian based machine 12.04 LTS or higher and that run it using sudo
#sudo ./run.sh
#script is installed on server machine
#CHANGE SUDOERS FILE RIGHTAWAY TO ALLOW YOU TO NOT ENTER PASSWORD FOR SUDO
reset
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "USER_NAME: (dustin)"
read USER_NAME
echo "SERVER_NAME: (gabby)"
read SERVER_NAME
echo "SERVER_DOMAIN: (srk9.com)"
read SERVER_DOMAIN
echo "HOSTNAME: $SERVER_NAME.$SERVER_DOMAIN"
read HOST_NAME
echo "Changing system hostname..."
echo "-->sudo cp /etc/hostname /etc/hostname.bak"
#sudo cp /etc/hostname /etc/hostname.bak
echo "-->sudo echo $HOST_NAME >> /etc/hostname"
#sudo ehco $HOST_NAME >> /etc/hostname
echo "-->sudo /etc/init.d/hostname.sh"
#sudo /etc/init.d/hostname.sh
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"
clear
echo "Going to update system now in preperation for new packages, press enter to continue."
read NULL
#install common debian packages
echo "updating system..."
echo "sudo apt-get -y update"
sudo apt-get -y update
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"
clear

echo "Going to now install some common system packages, press enter to continue."
read NULL
#echo "checking for build-essential..."
#which g++
#which dpkg
#which make
sudo apt-get -y install build-essential
sudo apt-get -y install libssl-dev
sudo apt-get -y install git-core
sudo apt-get -y install nginx
sudo apt-get -y install mongo
sudo apt-get -y install htop
sudo apt-get -y install atop
sudo apt-get -y install vim

#setup VIM
#git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
#cat templates/vimrc.template >> ~/.vimrc

echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"

#setup NVM
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
#manual install below but requires you add lines to bash profile
#git clone https://github.com/creationix/nvm.git ~/.nvm
#source ~/.nvm/nvm.sh


clear
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"
#setup NODE

clear
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"
#install MONGODB

clear
echo "Going to install MONGODB now, press enter to continue"
read NULL
#http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-10gen
#sudo service mongodb start
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"

clear
echo "Going to now install some common node packages for global use, press enter to continue."
read NULL
sudo npm install node-dev -g
sudo npm install coffee-script -g
sudo npm install shelljs -g
sudo npm install express -g
sudo npm install forever -g #requires node 0.8.x
sudo npm install jade -g
sudo npm install mongodb -g
sudo npm install mongodb-wrapper -g
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"
#setup DNS SERVER
#setup GIT USER
#setup a git server (http://www.vogella.com/articles/GitHosting/article.html)
#sudo adduser git
#THIS IS BETTER TO DO IN A SEPERATE SCRIPT


clear
#install mainframe
#install mainframe-server
#save key to env for session
#read AWSACCESSKEY
#save key to env for session
#read AWSSECERETKEY
#install AWSSDK if not already
which g++
which make
which node
which npm
which nginx
which mongodb
which vim
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"

clear
echo "Going to now upgrade system, press enter to continue"
read NULL
echo "upgrading system..."
echo "sudo apt-get -yq upgrade..."
sudo apt-get -y upgrade
sudo apt-get autoremove
echo "---------------------------------------------"
echo "---------------------------------------------"
echo "---------------------------------------------"

clear
echo "finished!"
