#!/bin/bash
#by rSuresh
source ./config.properties 2>&1
source ./update_functions.sh 2>&1
# Detials got from config.properties
# Taking backup for the current running service.
# Call function to check the DNS path for new agent.

if [ -f "$EPA_UPDATE_PATH/$RENAME_EPA_FILE" ] 
then

	mkdir $LOCAL_PATH/$EPA_OLD_VERSION
	mv $EPA_UPDATE_PATH/$RENAME_EPA_FILE $LOCAL_PATH/$EPA_OLD_VERSION/$RENAME_EPA_FILE
	echo "Old file got backed up to $LOCAL_PATH/$EPA_OLD_VERSION folder"
	echo "Old file got backed up to $LOCAL_PATH/$EPA_OLD_VERSION" >> update.log
	checkFileLocation

else
	read -p "File '${RENAME_EPA_FILE}' not found. Old service is not avaiable in upgrade. Do you want to continue?" serviceyesOrNo
	case $serviceyesOrNo in
        y|Y|yes|YES ) checkFileLocation ;; 
        n|N|NO|no ) exit ;;  
        exit|EXIT|q ) exit ;;
        * ) ;;
    esac
fi
