check_os.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 6+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. if [ -e /etc/redhat-release ]; then
  11. OS=CentOS
  12. [ ! -e "$(which lsb_release)" ] && { yum -y install redhat-lsb-core; clear; }
  13. CentOS_ver=$(lsb_release -sr | awk -F. '{print $1}')
  14. [ "${CentOS_ver}" == '17' ] && CentOS_ver=7
  15. elif [ -n "$(grep 'Amazon Linux' /etc/issue)" ]; then
  16. OS=CentOS
  17. CentOS_ver=7
  18. elif [ -n "$(grep 'bian' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Debian" ]; then
  19. OS=Debian
  20. [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  21. Debian_ver=$(lsb_release -sr | awk -F. '{print $1}')
  22. elif [ -n "$(grep 'Deepin' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Deepin" ]; then
  23. OS=Debian
  24. [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  25. Debian_ver=8
  26. elif [ -n "$(grep -w 'Kali' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Kali" ]; then
  27. OS=Debian
  28. [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  29. if [ -n "$(grep 'VERSION="2016.*"' /etc/os-release)" ]; then
  30. Debian_ver=8
  31. elif [ -n "$(grep 'VERSION="2017.*"' /etc/os-release)" ]; then
  32. Debian_ver=9
  33. elif [ -n "$(grep 'VERSION="2018.*"' /etc/os-release)" ]; then
  34. Debian_ver=9
  35. fi
  36. elif [ -n "$(grep 'Ubuntu' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Ubuntu" -o -n "$(grep 'Linux Mint' /etc/issue)" ]; then
  37. OS=Ubuntu
  38. [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  39. Ubuntu_ver=$(lsb_release -sr | awk -F. '{print $1}')
  40. [ -n "$(grep 'Linux Mint 18' /etc/issue)" ] && Ubuntu_ver=16
  41. elif [ -n "$(grep 'elementary' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'elementary' ]; then
  42. OS=Ubuntu
  43. [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  44. Ubuntu_ver=16
  45. else
  46. echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
  47. kill -9 $$
  48. fi
  49. if [ "$(uname -r | awk -F- '{print $3}' 2>/dev/null)" == "Microsoft" ]; then
  50. Wsl=true
  51. fi
  52. if [ "$(getconf WORD_BIT)" == "32" ] && [ "$(getconf LONG_BIT)" == "64" ]; then
  53. OS_BIT=64
  54. SYS_BIT_j=x64 #jdk
  55. SYS_BIT_a=x86_64 #mariadb
  56. SYS_BIT_b=x86_64 #mariadb
  57. SYS_BIT_c=x86_64 #ZendGuardLoader
  58. SYS_BIT_d=x86-64 #ioncube
  59. else
  60. OS_BIT=32
  61. SYS_BIT_j=i586
  62. SYS_BIT_a=x86
  63. SYS_BIT_b=i686
  64. SYS_BIT_c=i386
  65. SYS_BIT_d=x86
  66. fi
  67. LIBC_YN=$(awk -v A=$(getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}') -v B=2.14 'BEGIN{print(A>=B)?"0":"1"}')
  68. [ ${LIBC_YN} == '0' ] && GLIBC_FLAG=linux-glibc_214 || GLIBC_FLAG=linux
  69. if uname -m | grep -Eqi "arm"; then
  70. armplatform="y"
  71. if uname -m | grep -Eqi "armv7"; then
  72. TARGET_ARCH="armv7"
  73. elif uname -m | grep -Eqi "armv8"; then
  74. TARGET_ARCH="arm64"
  75. else
  76. TARGET_ARCH="unknown"
  77. fi
  78. fi
  79. THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
  80. # Percona binary: https://www.percona.com/doc/percona-server/5.7/installation.html#installing-percona-server-from-a-binary-tarball
  81. if [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -lt 14 >/dev/null 2>&1 ]; then
  82. sslLibVer=ssl100
  83. elif [[ "${CentOS_ver}" =~ ^[6-7]$ ]]; then
  84. sslLibVer=ssl101
  85. elif [ ${Debian_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 14 >/dev/null 2>&1 ]; then
  86. sslLibVer=ssl102
  87. else
  88. sslLibVer=unknown
  89. fi