check_os.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. elif [ -n "$(grep Ubuntu /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Ubuntu' -o -n "$(grep 'Linux Mint' /etc/issue)" ]; then
  27. OS=Ubuntu
  28. [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  29. Ubuntu_version=$(lsb_release -sr | awk -F. '{print $1}')
  30. [ -n "$(grep 'Linux Mint 18' /etc/issue)" ] && Ubuntu_version=16
  31. else
  32. echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
  33. kill -9 $$
  34. fi
  35. if uname -m | grep -Eqi "arm"; then
  36. armPlatform="y"
  37. if uname -m | grep -Eqi "armv7"; then
  38. TARGET_ARCH="armv7"
  39. elif uname -m | grep -Eqi "armv8"; then
  40. TARGET_ARCH="arm64"
  41. else
  42. TARGET_ARCH="unknown"
  43. fi
  44. fi
  45. if [ $(getconf WORD_BIT) == 32 ] && [ $(getconf LONG_BIT) == 64 ]; then
  46. OS_BIT=64
  47. SYS_BIG_FLAG=x64 #jdk
  48. SYS_BIT_a=x86_64;SYS_BIT_b=x86_64; #mariadb
  49. else
  50. OS_BIT=32
  51. SYS_BIG_FLAG=i586
  52. SYS_BIT_a=x86;SYS_BIT_b=i686;
  53. fi
  54. LIBC_YN=$(awk -v A=$(getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}') -v B=2.14 'BEGIN{print(A>=B)?"0":"1"}')
  55. [ $LIBC_YN == '0' ] && GLIBC_FLAG=linux-glibc_214 || GLIBC_FLAG=linux
  56. THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
  57. # Percona
  58. if [ -f "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0" ]; then
  59. if [ "${Debian_version}" == "6" ]; then
  60. sslLibVer=ssl098
  61. else
  62. sslLibVer=ssl100
  63. fi
  64. elif [ -f "/usr/lib64/libssl.so.10" ]; then
  65. if [ "${CentOS_RHEL_version}" == "5" ]; then
  66. sslLibVer=ssl098e
  67. else
  68. sslLibVer=ssl101
  69. fi
  70. fi