check_os.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. # http://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. if [ -f /etc/redhat-release -o -n "`grep 'Aliyun Linux release6 15' /etc/issue`" ];then
  11. OS=CentOS
  12. [ -n "$(grep ' 7\.' /etc/redhat-release)" ] && CentOS_RHEL_version=7
  13. [ -n "$(grep ' 6\.' /etc/redhat-release)" ] && CentOS_RHEL_version=6
  14. [ -n "$(grep ' 5\.' /etc/redhat-release)" ] && CentOS_RHEL_version=5
  15. elif [ -n "`grep bian /etc/issue`" ];then
  16. OS=Debian
  17. elif [ -n "`grep Ubuntu /etc/issue`" ];then
  18. OS=Ubuntu
  19. . /etc/lsb-release
  20. Ubuntu_version=${DISTRIB_RELEASE%\.*}
  21. else
  22. echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
  23. kill -9 $$
  24. fi
  25. if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then
  26. OS_BIT=64
  27. SYS_BIG_FLAG=x64 #jdk
  28. SYS_BIT_a=x86_64;SYS_BIT_b=x86_64; #mariadb
  29. else
  30. OS_BIT=32
  31. SYS_BIG_FLAG=i586
  32. SYS_BIT_a=x86;SYS_BIT_b=i686;
  33. fi
  34. OS_command(){
  35. if [ $OS == 'CentOS' ];then
  36. echo -e $OS_CentOS | bash
  37. elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then
  38. echo -e $OS_Debian_Ubuntu | bash
  39. else
  40. echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
  41. kill -9 $$
  42. fi
  43. }