1
0

check_os.sh 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. if [ -n "$(grep 'Aliyun Linux release' /etc/issue)" -o -e /etc/redhat-release ]; then
  11. OS=CentOS
  12. [ -n "$(grep ' 7\.' /etc/redhat-release)" ] && CentOS_RHEL_version=7
  13. [ -n "$(grep ' 6\.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release6 15' /etc/issue)" ] && CentOS_RHEL_version=6
  14. [ -n "$(grep ' 5\.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release5' /etc/issue)" ] && CentOS_RHEL_version=5
  15. elif [ -n "$(grep 'Amazon Linux AMI release' /etc/issue)" -o -e /etc/system-release ]; then
  16. OS=CentOS
  17. CentOS_RHEL_version=6
  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_version=$(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_version=$(lsb_release -sr | awk -F. '{print $1}')
  26. # kali rolling
  27. elif [ -n "$(grep 'Kali GNU/Linux Rolling' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Kali" ]; then
  28. OS=Debian
  29. [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  30. if [ -n "$(grep 'VERSION="2016.*"' /etc/os-release)" ]; then
  31. Debian_version=8
  32. else
  33. echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
  34. kill -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_version=$(lsb_release -sr | awk -F. '{print $1}')
  40. [ -n "$(grep 'Linux Mint 18' /etc/issue)" ] && Ubuntu_version=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_version=16
  45. else
  46. echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
  47. kill -9 $$
  48. fi
  49. if [ "$(getconf WORD_BIT)" == "32" ] && [ "$(getconf LONG_BIT)" == "64" ]; then
  50. OS_BIT=64
  51. SYS_BIG_FLAG=x64 #jdk
  52. SYS_BIT_a=x86_64;SYS_BIT_b=x86_64; #mariadb
  53. else
  54. OS_BIT=32
  55. SYS_BIG_FLAG=i586
  56. SYS_BIT_a=x86;SYS_BIT_b=i686;
  57. fi
  58. LIBC_YN=$(awk -v A=$(getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}') -v B=2.14 'BEGIN{print(A>=B)?"0":"1"}')
  59. [ $LIBC_YN == '0' ] && GLIBC_FLAG=linux-glibc_214 || GLIBC_FLAG=linux
  60. if uname -m | grep -Eqi "arm"; then
  61. armPlatform="y"
  62. if uname -m | grep -Eqi "armv7"; then
  63. TARGET_ARCH="armv7"
  64. elif uname -m | grep -Eqi "armv8"; then
  65. TARGET_ARCH="arm64"
  66. else
  67. TARGET_ARCH="unknown"
  68. fi
  69. fi
  70. THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
  71. # Percona
  72. if [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then
  73. if [ "${Debian_version}" == '6' ]; then
  74. sslLibVer=ssl098
  75. else
  76. sslLibVer=ssl100
  77. fi
  78. elif [ "${OS}" == "CentOS" ]; then
  79. if [ "${CentOS_RHEL_version}" == '5' ]; then
  80. sslLibVer=ssl098e
  81. else
  82. sslLibVer=ssl101
  83. fi
  84. else
  85. sslLibVer=unknown
  86. fi