#!/bin/sh
module_name=$1
target_host=$2

jenkins_host=192.168.192.191
target_host=$target_host
function copy_to()
{
	module=$1
	module_path=/home/quant_group/jenkins/workspace/build_${module}/dist.tar.gz
	if [[ -f ${module_path} ]]
	then
		scp /home/quant_group/jenkins/workspace/build_${module}/dist.tar.gz root@${target_host}:/home/quant_group/deploy_backup/${module}/
	else
		echo '${module}/dist.tar.gz does not exit'
   		exit -1
	fi
	
}

if [[ "${module_name}" = "ALL" ]]
then
	modules='di-ting-ui xyqb-ui pay-center-ui'
	for module in $modules
	do
	    copy_to ${module}
        echo ${module}
	done
elif [[ "${module_name}" = "" ]]
then
   echo 'Fail module name is empty'
   exit -1
else
	copy_to ${module_name}
 	echo ${module_name}
fi