download_voice_code.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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: ubuntu14.04_x64_indigo${normal}"
  32. echo -e "${green}2: ubuntu16.04_x64_kinetic${normal}"
  33. echo -e "${green}3: raspberry_jessie_indigo${normal}"
  34. echo -e "${green}4: raspberry_ubuntuMate16.04_kinetic${normal}"
  35. while [ $SELECT_OK == "false" ]
  36. do
  37. read -p "Please select download branch code based on your device and ros version: " index
  38. case $index in
  39. 1)GIT_BRANCH="ubuntu16.04_kinetic"
  40. SELECT_OK="true";;
  41. 2)GIT_BRANCH="raspberry_kinetic"
  42. SELECT_OK="true";;
  43. 3)GIT_BRANCH="master"
  44. SELECT_OK="true";;
  45. *) echo -e "${red}Selected index error! ${normal}";;
  46. esac
  47. done
  48. echo -e "${green} Now will try git clone ${GIT_BRANCH} branch code...${normal}"
  49. #check if exists setup_config.sh or ros_voice_system folder
  50. echo -e "${green} 1: Check if need download voice source code ${normal}"
  51. if [ ! -f "setup_config.sh" ] && [ ! -d "ros_voice_system" ]
  52. then
  53. sudo apt-get install -y git
  54. if [ $? -eq 0 ]
  55. then
  56. git clone -b ${GIT_BRANCH} https://code.corvin.cn:3000/ros_voice_system.git
  57. if [ $? -ne 0 ]
  58. then
  59. echo -e "${red}ERROR! Git clone source code unknown error, please retry later...${normal}"
  60. exit 1
  61. fi
  62. else
  63. echo -e "${red}Can't install git pkg, please retry install later...${normal}"
  64. exit 2
  65. fi
  66. else
  67. echo -e "${red}Already download ros_voice_system source code, now will exit...${normal}"
  68. exit 3
  69. fi
  70. #git clone code over,now will auto invoke bash to compile souce code
  71. echo -e "${green} 2: Will auto config and compile ros_voice_system code ${normal}"
  72. cd ${FILE_PATH}/ros_voice_system/scripts/
  73. chmod +x setup_config.sh
  74. . ./setup_config.sh
  75. exit 0