check_os.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 bian /etc/issue`" -o "`lsb_release -is 2>/dev/null`" == 'Debian' ];then
  16. OS=Debian
  17. [ ! -e "`which lsb_release`" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  18. Debian_version=`lsb_release -sr | awk -F. '{print $1}'`
  19. elif [ -n "`grep Deepin /etc/issue`" -o "`lsb_release -is 2>/dev/null`" == 'Deepin' ];then
  20. OS=Debian
  21. [ ! -e "`which lsb_release`" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  22. Debian_version=`lsb_release -sr | awk -F. '{print $1}'`
  23. elif [ -n "`grep Ubuntu /etc/issue`" -o "`lsb_release -is 2>/dev/null`" == 'Ubuntu' -o -n "`grep 'Linux Mint' /etc/issue`" ];then
  24. OS=Ubuntu
  25. [ ! -e "`which lsb_release`" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
  26. Ubuntu_version=`lsb_release -sr | awk -F. '{print $1}'`
  27. [ -n "`grep 'Linux Mint 18' /etc/issue`" ] && Ubuntu_version=16
  28. else
  29. echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
  30. kill -9 $$
  31. fi
  32. if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then
  33. OS_BIT=64
  34. SYS_BIG_FLAG=x64 #jdk
  35. SYS_BIT_a=x86_64;SYS_BIT_b=x86_64; #mariadb
  36. else
  37. OS_BIT=32
  38. SYS_BIG_FLAG=i586
  39. SYS_BIT_a=x86;SYS_BIT_b=i686;
  40. fi
  41. LIBC_YN=$(awk -v A=`getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}'` -v B=2.14 'BEGIN{print(A>=B)?"0":"1"}')
  42. [ $LIBC_YN == '0' ] && GLIBC_FLAG=linux-glibc_214 || GLIBC_FLAG=linux
  43. THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)