check_os.sh 3.8 KB

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