install.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. #
  3. # Copyright 2021-2022 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 update \
  46. && apt upgrade \
  47. && apt install -y ffmpeg 2> /dev/null \
  48. ;; \
  49. Alpine ) \
  50. apk add ffmpeg 2> /dev/null \
  51. ;; \
  52. *) \
  53. yum install -y ffmpeg 2> /dev/null \
  54. ;; \
  55. esac
  56. echo "install success";