pre_required_helper.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/bash
  2. #This script will compile and install the dependencies build with support for cnstream ubuntu or centos.
  3. CWD="$( cd "$( dirname "$0" )" && pwd )"
  4. SUDO_CMD=""
  5. command_exists() {
  6. if ! [[ -x $(command -v "$1") ]]; then
  7. return 1
  8. fi
  9. return 0
  10. }
  11. check_sudo(){
  12. if command_exists "sudo"; then
  13. SUDO_CMD="sudo"
  14. fi
  15. }
  16. download() {
  17. echo ""
  18. echo "download $1"
  19. echo "======================="
  20. if [ -f "$CWD/$1.done" ]; then
  21. echo "$1 already exist. Remove $CWD/$1.done lockfile to re-download it."
  22. return 1
  23. fi
  24. return 0
  25. }
  26. download_done () {
  27. touch "$CWD/$1.done"
  28. }
  29. installAptLibs() {
  30. ${SUDO_CMD} apt-get update
  31. ${SUDO_CMD} apt-get -y --force-yes install libopencv-dev\
  32. libgflags-dev\
  33. libgoogle-glog-dev\
  34. libfreetype6\
  35. ttf-wqy-zenhei\
  36. cmake\
  37. libsdl2-dev\
  38. curl libcurl4-openssl-dev\
  39. librdkafka-dev\
  40. lcov
  41. }
  42. installYumLibs() {
  43. ${SUDO_CMD} yum -y install opencv-devel.x86_64\
  44. gflags-devel\
  45. glog-devel\
  46. cmake3.x86_64\
  47. freetype-devel\
  48. SDL2_gfx-devel.x86_64\
  49. wqy-zenhei-fonts\
  50. curl libcurl-devel \
  51. librdkafka-devel \
  52. lcov
  53. ${SUDO_CMD} yum install -y epel-release rpm
  54. #remove below line for long time to update
  55. #${SUDO_CMD} yum update -y
  56. ${SUDO_CMD} rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
  57. ${SUDO_CMD} rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
  58. ${SUDO_CMD} yum install ffmpeg ffmpeg-devel -y
  59. echo "Should find ffmpeg libraries in /usr/lib64 and header files in /usr/include/ffmepg"
  60. }
  61. installLibs() {
  62. echo "Installing prerequisites"
  63. . /etc/os-release
  64. case "$ID" in
  65. ubuntu | linuxmint ) installAptLibs ;;
  66. * ) installYumLibs ;;
  67. esac
  68. }
  69. check_sudo
  70. installLibs
  71. font_path=`fc-list :lang=zh | grep "wqy-zenhei.ttc"`
  72. ${SUDO_CMD} ln -sf ${font_path%%:*} /usr/include/wqy-zenhei.ttc
  73. if download "live555"; then
  74. ./download_live.sh
  75. download_done "live555";
  76. fi
  77. echo "Complete!"
  78. ## END ##