Fix toolchain download fail.

Change-Id: I2cf7093210dc635e48bf3e26d57d3ca5e1b43ccd
diff --git a/build.sh b/build.sh
index 3c6b547..c0bc591 100755
--- a/build.sh
+++ b/build.sh
@@ -5,10 +5,26 @@
 	exit 1
 fi
 
-if [ ! -d ~/openwrt_toolchains ];then
-	echo "Start download toolchains."
-	git clone "ssh://b.liu@192.168.1.198:29418/mbtk_toolchains_for_asr_linux" ~/openwrt_toolchains && scp -p -P 29418 b.liu@192.168.1.198:hooks/commit-msg ~/openwrt_toolchains/.git/hooks/
-fi
+function mbtk_toolchain_download()
+{
+	MBTK_TOOLCHAIN_DIR=~/openwrt_toolchains
+
+	# git clone "ssh://b.liu@192.168.1.198:29418/ASR1803_openwrt_mbtk_source" mbtk_source && scp -p -P 29418 b.liu@192.168.1.198:hooks/commit-msg "mbtk_source/.git/hooks/"
+	GIT_URL=`grep "url" .git/config | cut -d " " -f 3 | \
+			 sed "s/ASR1803_openwrt_mbtk_source/mbtk_toolchains_for_asr_linux/"`
+
+	GIT_IP=`echo $GIT_URL | cut -d ":" -f 2`
+	GIT_IP=${GIT_IP: 2}
+	GIT_PORT=`echo $GIT_URL | cut -d "/" -f 3 | cut -d ":" -f 2`
+
+	if [ ! -d $MBTK_TOOLCHAIN_DIR ];then
+		echo "Start download toolchains."
+		# git clone "ssh://b.liu@192.168.1.198:29418/mbtk_toolchains_for_asr_linux" ~/openwrt_toolchains && scp -p -P 29418 b.liu@192.168.1.198:hooks/commit-msg ~/openwrt_toolchains/.git/hooks/
+		git clone "$GIT_URL" $MBTK_TOOLCHAIN_DIR && scp -p -P $GIT_PORT $GIT_IP:hooks/commit-msg "$MBTK_TOOLCHAIN_DIR/.git/hooks/"
+	fi
+}
+
+mbtk_toolchain_download
 
 # static / shared
 export BUILD_LIB_TYPE=shared