install.sh 909 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # 函数名:check_pkg_version
  3. # 参数1:pkg_ver
  4. # 参数2:min_ver
  5. # 参数3:max_ver
  6. check_pkg_version() {
  7. pkg_ver=$1
  8. min_ver=$2
  9. max_ver=$3
  10. # 判断版本号是否在范围内
  11. if dpkg --compare-versions "$min_ver" "<=" "$pkg_ver" \
  12. && dpkg --compare-versions "$max_ver" ">=" "$pkg_ver"
  13. then
  14. return 1
  15. else
  16. return 0
  17. fi
  18. }
  19. # cmake 安装,由于rabbitmq安装版本要求最低为3.22,所以需要重新安装cmake
  20. cmake_ver=$(cmake --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
  21. check_pkg_version "$cmake_ver" 3.22.0 3.26.0
  22. if [ $? -eq 1 ]
  23. then
  24. echo "cmake version: " "$cmake_ver"
  25. else
  26. echo "Reinstall cmake to version: 3.26.0"
  27. sudo apt autoremove cmake
  28. # 架构管理
  29. arch=$(uname -m)
  30. if [ "$arch" = "x86_64" ]
  31. then
  32. cd cmake_x86_64 || exit
  33. fi
  34. if [ "$arch" = "aarch64" ]
  35. then
  36. cd cmake_aarch64 || exit
  37. fi
  38. ./install.sh
  39. cd ..
  40. fi