utils.sh 845 B

1234567891011121314151617181920212223242526272829303132
  1. function 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. if [ "$country" == "China" ]; then
  8. local url_rttpkgtool="https://gitee.com/unicornx/rttpkgtool.git"
  9. else
  10. local url_rttpkgtool="https://github.com/plctlab/rttpkgtool.git"
  11. fi
  12. #echo "rttpkgtool URL: ${url_rttpkgtool}"
  13. if [ ! -d ${project_path}/rttpkgtool ]; then
  14. echo "rttpkgtool does not exist, clone it from ${url_rttpkgtool}"
  15. git clone -b for-k230 ${url_rttpkgtool} ${project_path}/rttpkgtool
  16. if [ $? -ne 0 ]; then
  17. echo "Failed to clone ${url_rttpkgtool} !"
  18. return 1
  19. fi
  20. else
  21. echo "rttpkgtool already exists"
  22. pushd ${project_path}/rttpkgtool
  23. git checkout for-k230
  24. git pull
  25. popd
  26. fi
  27. return 0
  28. }