#!/bin/bash
source ./config.properties 2>&1
source ./update_functions.sh 2>&1
# Detials got from config.properties
# Display the old version name
# Enquire user for new agent name
# Get the DNS location if needed.

echo "Old Version: "  $EPA_OLD_VERSION
echo "Old Version: "  $EPA_OLD_VERSION >> update.log

read -p "Enter Agent New Version: "  new_version

read -p "Is Update Agent on DNS? - yes Or No: " localdownload
if [[ $localdownload == "yes" || $localdownload == "YES" || $localdownload == "y"  ]]; then
	downloadDetail "yes" 
	read -p "Enter Agent DNS URL: " URL_Name
	sed -i "s|CLIENT_URL.*|CLIENT_URL='"$URL_Name"' |" ./config.properties

elif [[ $localdownload == "no" || $localdownload == "NO" || $localdownload == "n" ]]; then
	downloadDetail "no" 
	if [[ -f "$LOCAL_PATH/$DEFAULT_FILE_NAME" ]]; then
		echo "Local File Present" 
		echo "Local File Present" >> update.log
	else
		echo "No Local File Present in "$LOCAL_PATH/$DEFAULT_FILE_NAME 
		echo "No Local File Present in "$LOCAL_PATH/$DEFAULT_FILE_NAME >> update.log

		exit
		#statements
	fi
else 
	exit
fi

#winUpgrade 2.3.6.5 2.3.7.8 https://dns.parablu.com/parablu_installables/master_testing/AGENTS/PROD/mycloud_2018Oct13_14112.3.6.9.7/
winUpgrade $new_version 
