install.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. #
  3. # Copyright 2023 EMQ Technologies Co., Ltd.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. set +e -x -u
  18. DISTRO='unknow'
  19. Get_Dist_Name()
  20. {
  21. if grep -Eqii "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
  22. DISTRO='CentOS'
  23. elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then
  24. DISTRO='RHEL'
  25. elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
  26. DISTRO='Aliyun'
  27. elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
  28. DISTRO='Fedora'
  29. elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
  30. DISTRO='Debian'
  31. elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
  32. DISTRO='Ubuntu'
  33. elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
  34. DISTRO='Raspbian'
  35. elif grep -Eqi "Alpine" /etc/issue || grep -Eq "Alpine" /etc/*-release; then
  36. DISTRO='Alpine'
  37. else
  38. DISTRO='unknow'
  39. fi
  40. echo $DISTRO;
  41. }
  42. Get_Dist_Name
  43. case $DISTRO in \
  44. Debian|Ubuntu|Raspbian ) \
  45. apt-get update \
  46. && apt-get install -y libczmq-dev 2> /dev/null \
  47. && apt-get clean \
  48. && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
  49. ;; \
  50. Alpine ) \
  51. apk add libzmq \
  52. ;; \
  53. *) \
  54. yum install -y zeromq 2> /dev/null \
  55. ;; \
  56. esac
  57. echo "install success";