download_voice_code.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. ##############################################################
  3. # Author: www.corvin.cn
  4. ##############################################################
  5. # Description: 该脚本只有在需要分发本代码时发送给其他人执行
  6. # 即可,其他人执行该脚本即可自动的下载语音相关所有源码。
  7. # 而且该脚本还可以在下载完成源码后,然后自动切换分支,
  8. # 更新当前分支代码与服务器代码同步,然后调用setup_config.sh
  9. # 脚本来自动配置编译环境,安装缺失软件包,编译整个源码。
  10. #
  11. ##############################################################
  12. # History:
  13. # 20171205 - init this bash file
  14. # 20171212 - 当git clone前首先来安装git,防止没有下载
  15. # 软件就开始git clone下载代码;
  16. # 20180102-增加可以下载树莓派分支代码功能,增加提示信息,让
  17. # 用户根据自己设备要求来选择相应分支代码;
  18. #
  19. ##############################################################
  20. green="\e[32;1m"
  21. red="\e[31m"
  22. blue="\e[34m"
  23. normal="\e[0m"
  24. FILE_PATH=$(dirname $(readlink -f "$0"))
  25. SELECT_OK="false"
  26. echo -e "${green}***************************************************************************** ${normal}\n"
  27. echo -e "${green}********** Welcome Download ROS Chinese Voice System Source Code ! ********** ${normal}\n"
  28. echo -e "${green}********** www.corvin.cn ********** ${normal}\n"
  29. echo -e "${green}***************************************************************************** ${normal}\n"
  30. echo -e "${green}In Server All Git Branches List Blow:${normal}"
  31. echo -e "${green}1: master${normal}"
  32. while [ $SELECT_OK == "false" ]
  33. do
  34. read -p "Please select download branch code based on your device and ros version: " index
  35. case $index in
  36. 1)GIT_BRANCH="master"
  37. SELECT_OK="true";;
  38. *) echo -e "${red}Selected index error! ${normal}";;
  39. esac
  40. done
  41. echo -e "${green} Now will try git clone ${GIT_BRANCH} branch code...${normal}"
  42. #check if exists setup_config.sh or ros_voice_system folder
  43. echo -e "${green} 1: Check if need download voice source code ${normal}"
  44. if [ ! -f "setup_config.sh" ] && [ ! -d "ros_voice_system" ]
  45. then
  46. sudo apt-get install -y git
  47. if [ $? -eq 0 ]
  48. then
  49. git clone -b ${GIT_BRANCH} https://code.corvin.cn:3000/corvin_zhang/ros_voice_system.git
  50. if [ $? -ne 0 ]
  51. then
  52. echo -e "${red}ERROR! Git clone source code unknown error, please retry later...${normal}"
  53. exit 1
  54. fi
  55. else
  56. echo -e "${red}Can't install git pkg, please retry install later...${normal}"
  57. exit 2
  58. fi
  59. else
  60. echo -e "${red}Already download ros_voice_system source code, now will exit...${normal}"
  61. exit 3
  62. fi
  63. #git clone code over,now will auto invoke bash to compile souce code
  64. echo -e "${green} 2: Will auto config and compile ros_voice_system code ${normal}"
  65. cd ${FILE_PATH}/ros_voice_system/scripts/
  66. chmod +x setup_config.sh
  67. . ./setup_config.sh
  68. exit 0