#!/bin/bash
#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
#   @filename: get_os_type
#   @author: 沈风
#   @date: 2024-09-23 10:40
#   @description: 获取当前操作系统类型
#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#

# 获取当前操作系统类型
function getOsType() {
  os_name=$(sed '/^NAME=/!d;s/.*=//' /etc/os-release)
  os_type=""
  if [[ ${os_name,,} =~ ^\"rocky ]]; then
    # 获取系统为: rocky8.6
    os_type=rocky8.6
  elif [[ ${os_name,,} =~ ^\"kylin ]]; then
    # 获取系统为: kylin10sp2
    os_type=kylin10sp2
  elif [[ ${os_name,,} =~ ^\"neokylin ]]; then
    # 获取系统为: neokylin
    os_type=neokylin
  else
    count=`cat /etc/centos-release | grep 7.9.2009 | wc -l`
    if [ $count -eq 0 ];then
        # 获取系统为: centos7.4
        os_type=centos7.4
    else
        # 获取系统为: centos7.9
        os_type=centos7.9
    fi
  fi;
}


