File: //smc/go2aliyun_client2.7.7_linux_x86_64/Check/Test/os_unsupport.sh
#!/bin/bash
test::os_unsupport() {
local src_os_type=$1
local tar_os_type=$2
declare -A os_map=(
["CentOS7"]="AnolisOS7 AnolisOS8 AliLinux2 AliLinux3 AliLinux3Pro"
["CentOS8"]="AnolisOS8 AliLinux3 AliLinux3Pro"
["AliLinux2"]="AliLinux3"
["AliLinux3"]="AliLinux3Pro"
["RedHat7"]="AliLinux3"
["RedHat8"]="AliLinux3"
)
# get current os type
os_name=$(cat /etc/os-release | grep "^NAME=" | cut -d "=" -f2 | awk -F\" '{print $2}')
os_version=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -d "=" -f2 | tr -d '\"')
cur_os_type="unsupport system"
if [[ "$os_name" == "CentOS Linux"* ]]; then
if [[ "$os_version" == "7"* ]]; then
cur_os_type="CentOS7"
elif [[ "$os_version" == "8"* ]]; then
cur_os_type="CentOS8"
fi
elif [[ "$os_name" == "Alibaba Cloud Linux"* ]]; then
if [[ "$os_version" == "2"* ]]; then
cur_os_type="AliLinux2"
elif [[ "$os_version" == "3"* ]]; then
cur_os_type="AliLinux3"
fi
elif [[ "$os_name" == "Red Hat Enterprise Linux"* ]]; then
if [[ "$os_version" == "7.9"* ]]; then
cur_os_type="RedHat7"
elif [[ "$os_version" == "8"* ]]; then
cur_os_type="RedHat8"
fi
else
echo "The OS Name '$os_name' With OS Version '$os_version' Is Not Support"
exit 111
fi
if [[ "$src_os_type" != "$cur_os_type" ]]; then
echo "Current OS Type Is '$cur_os_type', Not '$src_os_type'"
exit 111
fi
if [[ "${os_map[$src_os_type]}"* =~ "$tar_os_type" ]]; then
exit 0
else
echo "'$src_os_type' to '$tar_os_type' Is Not Support"
exit 111
fi
exit 0
}
test::os_unsupport $1 $2