Browse Source

[feat] Update check_os.sh

lj2007331@gmail.com 3 years ago
parent
commit
a03675f932
5 changed files with 46 additions and 42 deletions
  1. 1 1
      backup_setup.sh
  2. 35 33
      include/check_os.sh
  3. 1 1
      include/check_sw.sh
  4. 1 1
      include/jemalloc.sh
  5. 8 6
      install.sh

+ 1 - 1
backup_setup.sh

@@ -182,7 +182,7 @@ fi
 
 
 if [ -n "`echo ${desc_bk} | grep -w 3`" ]; then
 if [ -n "`echo ${desc_bk} | grep -w 3`" ]; then
   if [ ! -e "/usr/local/bin/ossutil" ]; then
   if [ ! -e "/usr/local/bin/ossutil" ]; then
-    wget -qc https://gosspublic.alicdn.com/ossutil/1.7.1/ossutil${OS_BIT} -O /usr/local/bin/ossutil
+    wget -qc https://gosspublic.alicdn.com/ossutil/1.7.3/ossutil${OS_BIT} -O /usr/local/bin/ossutil
     chmod +x /usr/local/bin/ossutil
     chmod +x /usr/local/bin/ossutil
   fi
   fi
   while :; do echo
   while :; do echo

+ 35 - 33
include/check_os.sh

@@ -15,47 +15,49 @@ if [ -e "/usr/bin/yum" ]; then
     sed -i 's@centos/RPM-GPG@centos-vault/RPM-GPG@g' /etc/yum.repos.d/CentOS-Base.repo
     sed -i 's@centos/RPM-GPG@centos-vault/RPM-GPG@g' /etc/yum.repos.d/CentOS-Base.repo
     [ -e /etc/yum.repos.d/epel.repo ] && rm -f /etc/yum.repos.d/epel.repo
     [ -e /etc/yum.repos.d/epel.repo ] && rm -f /etc/yum.repos.d/epel.repo
   fi
   fi
-  command -v lsb_release >/dev/null 2>&1 || { [ -e "/etc/euleros-release" ] && yum -y install euleros-lsb || yum -y install redhat-lsb-core; clear; }
+  if ! command -v lsb_release >/dev/null 2>&1; then
+    if [ -e "/etc/euleros-release" ]; then
+      yum -y install euleros-lsb
+    elif [ -e "/etc/openeuler-release" ]; then
+      yum -y install openeuler-lsb
+    else
+      yum -y install redhat-lsb-core
+    fi
+    clear
+  fi
 fi
 fi
+
 if [ -e "/usr/bin/apt-get" ]; then
 if [ -e "/usr/bin/apt-get" ]; then
   PM=apt-get
   PM=apt-get
-  command -v lsb_release >/dev/null 2>&1 || { apt-get -y update; apt-get -y install lsb-release; clear; }
+  command -v lsb_release >/dev/null 2>&1 || { apt-get -y update > /dev/null; apt-get -y install lsb-release; clear; }
 fi
 fi
 
 
 command -v lsb_release >/dev/null 2>&1 || { echo "${CFAILURE}${PM} source failed! ${CEND}"; kill -9 $$; }
 command -v lsb_release >/dev/null 2>&1 || { echo "${CFAILURE}${PM} source failed! ${CEND}"; kill -9 $$; }
 
 
 # Get OS Version
 # Get OS Version
-if [ -e /etc/redhat-release ]; then
-  OS=CentOS
-  CentOS_ver=$(lsb_release -sr | awk -F. '{print $1}')
-  [ -n "$(lsb_release -is | grep -Ei 'Alibaba|Aliyun')" ] && { CentOS_ver=7; Aliyun_ver=$(lsb_release -rs); }
-  [[ "$(lsb_release -is)" =~ ^EulerOS$ ]] && { CentOS_ver=7; EulerOS_ver=$(lsb_release -rs); }
-  [ "$(lsb_release -is)" == 'Fedora' ] && [ ${CentOS_ver} -ge 19 >/dev/null 2>&1 ] && { CentOS_ver=7; Fedora_ver=$(lsb_release -rs); }
-elif [ -n "$(grep 'Amazon Linux' /etc/issue)" -o -n "$(grep 'Amazon Linux' /etc/os-release)" ]; then
-  OS=CentOS
-  CentOS_ver=7
-elif [ -n "$(grep 'bian' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Debian" ]; then
-  OS=Debian
-  Debian_ver=$(lsb_release -sr | awk -F. '{print $1}')
-elif [ -n "$(grep 'Deepin 20' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Deepin" ]; then
-  OS=Debian
-  Debian_ver=10
-elif [ -n "$(grep -w 'Kali' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Kali" ]; then
-  OS=Debian
-  if [ -n "$(grep 'VERSION="2016.*"' /etc/os-release)" ]; then
-    Debian_ver=8
-  elif [ -n "$(grep 'VERSION="2017.*"' /etc/os-release)" ]; then
-    Debian_ver=9
-  elif [ -n "$(grep 'VERSION="2018.*"' /etc/os-release)" ]; then
-    Debian_ver=9
+OS=$(lsb_release -is)
+if [[ "${OS}" =~ ^CentOS$|^RedHat$|^Fedora$|^Amazon$|^Alibaba$|^Aliyun$|^EulerOS$|^openEuler$ ]]; then
+  LikeOS=CentOS
+  CentOS_ver=$(lsb_release -rs | awk -F. '{print $1}')
+  [[ "${OS}" =~ ^Fedora$ ]] && [ ${CentOS_ver} -ge 19 >/dev/null 2>&1 ] && { CentOS_ver=7; Fedora_ver=$(lsb_release -rs); }
+  [[ "${OS}" =~ ^Amazon$|^Alibaba$|^Aliyun$|^EulerOS$|^openEuler$ ]] && CentOS_ver=7
+elif [[ "${OS}" =~ ^Debian$|^Deepin$|^Uos$|^Kali$ ]]; then
+  LikeOS=Debian
+  Debian_ver=$(lsb_release -rs | awk -F. '{print $1}')
+  [[ "${OS}" =~ ^Deepin$|^Uos$ ]] && [[ "${Debian_ver}" =~ ^20$ ]] && Debian_ver=10
+  [[ "${OS}" =~ ^Kali$ ]] && [[ "${Debian_ver}" =~ ^202 ]] && Debian_ver=10
+elif [[ "${OS}" =~ ^Ubuntu$|^LinuxMint$|^elementary$ ]]; then
+  LikeOS=Ubuntu
+  Ubuntu_ver=$(lsb_release -rs | awk -F. '{print $1}')
+  if [[ "${OS}" =~ ^LinuxMint$ ]]; then
+    [[ "${Ubuntu_ver}" =~ ^18$ ]] && Ubuntu_ver=16
+    [[ "${Ubuntu_ver}" =~ ^19$ ]] && Ubuntu_ver=18
+    [[ "${Ubuntu_ver}" =~ ^20$ ]] && Ubuntu_ver=20
+  fi
+  if [[ "${OS}" =~ ^elementary$ ]]; then
+    [[ "${Ubuntu_ver}" =~ ^5$ ]] && Ubuntu_ver=18
+    [[ "${Ubuntu_ver}" =~ ^6$ ]] && Ubuntu_ver=20
   fi
   fi
-elif [ -n "$(grep 'Ubuntu' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Ubuntu" -o -n "$(grep 'Linux Mint' /etc/issue)" ]; then
-  OS=Ubuntu
-  Ubuntu_ver=$(lsb_release -sr | awk -F. '{print $1}')
-  [ -n "$(grep 'Linux Mint 18' /etc/issue)" ] && Ubuntu_ver=16
-elif [ -n "$(grep 'elementary' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'elementary' ]; then
-  OS=Ubuntu
-  Ubuntu_ver=16
 fi
 fi
 
 
 # Check OS Version
 # Check OS Version
@@ -109,7 +111,7 @@ THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
 # Percona binary: https://www.percona.com/doc/percona-server/5.7/installation.html#installing-percona-server-from-a-binary-tarball
 # Percona binary: https://www.percona.com/doc/percona-server/5.7/installation.html#installing-percona-server-from-a-binary-tarball
 if [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ]; then
 if [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ]; then
   sslLibVer=ssl100
   sslLibVer=ssl100
-elif [[ "${CentOS_ver}" =~ ^[6-7]$ ]] && [ "$(lsb_release -is)" != 'Fedora' ]; then
+elif [[ "${CentOS_ver}" =~ ^[6-7]$ ]] && [ "${OS}" != 'Fedora' ]; then
   sslLibVer=ssl101
   sslLibVer=ssl101
 elif [ ${Debian_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 16 >/dev/null 2>&1 ]; then
 elif [ ${Debian_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 16 >/dev/null 2>&1 ]; then
   sslLibVer=ssl102
   sslLibVer=ssl102

+ 1 - 1
include/check_sw.sh

@@ -131,7 +131,7 @@ installDepsUbuntu() {
 
 
 installDepsBySrc() {
 installDepsBySrc() {
   pushd ${oneinstack_dir}/src > /dev/null
   pushd ${oneinstack_dir}/src > /dev/null
-  if [ "${OS}" == 'CentOS' ] && [ "${CentOS_ver}" == '6' ]; then
+  if [ "${LikeOS}" == 'CentOS' ] && [ "${CentOS_ver}" == '6' ]; then
     # upgrade autoconf for CentOS6
     # upgrade autoconf for CentOS6
     rpm -Uvh autoconf-2.69-12.2.noarch.rpm
     rpm -Uvh autoconf-2.69-12.2.noarch.rpm
   fi
   fi

+ 1 - 1
include/jemalloc.sh

@@ -17,7 +17,7 @@ Install_Jemalloc() {
     make -j ${THREAD} && make install
     make -j ${THREAD} && make install
     popd > /dev/null
     popd > /dev/null
     if [ -f "/usr/local/lib/libjemalloc.so" ]; then
     if [ -f "/usr/local/lib/libjemalloc.so" ]; then
-      if [ "${OS_BIT}" == '64' -a "${OS}" == 'CentOS' ]; then
+      if [ "${OS_BIT}" == '64' -a "${LikeOS}" == 'CentOS' ]; then
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib64/libjemalloc.so.1
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib64/libjemalloc.so.1
       else
       else
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so.1
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so.1

+ 8 - 6
install.sh

@@ -37,7 +37,7 @@ dbinstallmethod=1
 
 
 version() {
 version() {
   echo "version: 2.4"
   echo "version: 2.4"
-  echo "updated date: 2021-04-01"
+  echo "updated date: 2021-05-18"
 }
 }
 
 
 Show_Help() {
 Show_Help() {
@@ -699,10 +699,11 @@ fi
 # install wget gcc curl python
 # install wget gcc curl python
 if [ ! -e ~/.oneinstack ]; then
 if [ ! -e ~/.oneinstack ]; then
   downloadDepsSrc=1
   downloadDepsSrc=1
-  [ "${PM}" == 'apt-get' ] && apt-get -y update
+  [ "${PM}" == 'apt-get' ] && apt-get -y update > /dev/null
   [ "${PM}" == 'yum' ] && yum clean all
   [ "${PM}" == 'yum' ] && yum clean all
   ${PM} -y install wget gcc curl python
   ${PM} -y install wget gcc curl python
   [ "${CentOS_ver}" == '8' ] && { yum -y install python36; sudo alternatives --set python /usr/bin/python3; }
   [ "${CentOS_ver}" == '8' ] && { yum -y install python36; sudo alternatives --set python /usr/bin/python3; }
+  clear
 fi
 fi
 
 
 # get the IP information
 # get the IP information
@@ -712,6 +713,7 @@ IPADDR_COUNTRY=$(./include/get_ipaddr_state.py ${PUBLIC_IPADDR})
 
 
 # Check download source packages
 # Check download source packages
 . ./include/check_download.sh
 . ./include/check_download.sh
+[ "${armplatform}" == "y" ] && dbinstallmethod=2
 checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
 checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
 
 
 # del openssl for jcloud
 # del openssl for jcloud
@@ -724,7 +726,7 @@ checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
 if [ ! -e ~/.oneinstack ]; then
 if [ ! -e ~/.oneinstack ]; then
   # Check binary dependencies packages
   # Check binary dependencies packages
   . ./include/check_sw.sh
   . ./include/check_sw.sh
-  case "${OS}" in
+  case "${LikeOS}" in
     "CentOS")
     "CentOS")
       installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
       installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
       . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
       . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
@@ -760,7 +762,7 @@ fi
 # Database
 # Database
 case "${db_option}" in
 case "${db_option}" in
   1)
   1)
-    [ "${OS}" == 'CentOS' ] && [ ${CentOS_ver} -le 6 >/dev/null 2>&1 ] && dbinstallmethod=1 && checkDownload
+    [ "${LikeOS}" == 'CentOS' ] && [ ${CentOS_ver} -le 6 >/dev/null 2>&1 ] && dbinstallmethod=1 && checkDownload
     . include/mysql-8.0.sh
     . include/mysql-8.0.sh
     Install_MySQL80 2>&1 | tee -a ${oneinstack_dir}/install.log
     Install_MySQL80 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
     ;;
@@ -793,8 +795,8 @@ case "${db_option}" in
     Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
     Install_MariaDB55 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
     ;;
   9)
   9)
-    [ "${OS}" == 'CentOS' ] && [ ${CentOS_ver} -le 6 >/dev/null 2>&1 ] && dbinstallmethod=1 && checkDownload
-    [ "${OS}" == 'CentOS' ] && [ "${CentOS_ver}" == '8' ] && dbinstallmethod=2 && checkDownload
+    [ "${LikeOS}" == 'CentOS' ] && [ ${CentOS_ver} -le 6 >/dev/null 2>&1 ] && dbinstallmethod=1 && checkDownload
+    [ "${LikeOS}" == 'CentOS' ] && [ "${CentOS_ver}" == '8' ] && dbinstallmethod=2 && checkDownload
     . include/percona-8.0.sh
     . include/percona-8.0.sh
     Install_Percona80 2>&1 | tee -a ${oneinstack_dir}/install.log
     Install_Percona80 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
     ;;