#!/bin/sh

bblue=`tput setab 4`
bgreen=`tput setab 2`
fwhite=`tput setaf 7`
reset=`tput sgr0`

HOST_MANAGER="10.104.4.113"
HOST_INTERNAL="10.104.4.146"

USER_HOST=deploy

upload_core() {
	echo "Are you sure? (y or n)"
	read CONFIRMATION

	if [ $CONFIRMATION = "y" ];then
		user=$1
		host=$2
		cd /var/www/html/
		scp -r * $user@$host:/var/www/html/
	fi	
}

upload_core_without_confirmation() {
	user=$1
	host=$2
	cd /var/www/html/
	scp -r * $user@$host:/var/www/html/
}

echo "${bgreen} Init Deploy in SERVER ${reset}"

echo "Select servers: "
echo " 0 - all "
echo " 1 - internal (.146)"

read SERVERS


if [ $SERVERS -eq 1 ];then
	echo "${bblue}${fwhite}Upload to INTERNAL ($HOST_INTERNAL) ${reset}"
	
	upload_core $USER_HOST $HOST_INTERNAL
fi

if [ $SERVERS -eq 0 ];then
	echo "${bblue}${fwhite}Upload to ALL SERVERS${reset}"
	
	upload_core_without_confirmation $USER_HOST $HOST_INTERNAL
	
fi
