1function download_rttpkgtool()
2{
3	local project_path=$1
4	local restult=$(curl -m 10 -s http://www.ip-api.com/json)
5	local country=$(echo $restult | sed 's/.*"country":"\([^"]*\)".*/\1/')
6	#echo "Country: $country"
7
8	if [ "$country" == "China" ]; then
9		local url_rttpkgtool="https://gitee.com/unicornx/rttpkgtool.git"
10	else
11		local url_rttpkgtool="https://github.com/plctlab/rttpkgtool.git"
12	fi
13	#echo "rttpkgtool URL: ${url_rttpkgtool}"
14
15	if [ ! -d ${project_path}/rttpkgtool ]; then
16		echo "rttpkgtool does not exist, clone it from ${url_rttpkgtool}"
17		git clone -b for-k230 ${url_rttpkgtool} ${project_path}/rttpkgtool
18
19		if [ $? -ne 0 ]; then
20			echo "Failed to clone ${url_rttpkgtool} !"
21			return 1
22		fi
23	else
24		echo "rttpkgtool already exists"
25		pushd ${project_path}/rttpkgtool
26		git checkout for-k230
27		git pull
28		popd
29	fi
30
31	return 0
32}
33