Fix a bug: when the Debian version is the Codename, an error will occur

This commit is contained in:
Samson-W 2021-02-22 12:08:40 +08:00
parent 64bececd2d
commit d6fca32f10
1 changed files with 28 additions and 14 deletions

View File

@ -22,14 +22,21 @@ is_centos_8()
is_debian_ge_10()
{
# For debian11
DEBIAN11CODENAME="bullseye"
if [ -r /etc/debian_version ]; then
if [ $(cat /etc/debian_version | awk -F"." '{print $1}') -ge 10 ]; then
debug "Debian version is greater than or equal to 10"
FNRET=0
else
debug "Debian version is less than 10"
FNRET=1
fi
if [ $(grep -cw "^$DEBIAN11CODENAME" /etc/debian_version) -eq 1 ]; then
debug "Debian version is greater than or equal to 10"
FNRET=0
return
fi
if [ $(cat /etc/debian_version | awk -F"." '{print $1}') -ge 10 ]; then
debug "Debian version is greater than or equal to 10"
FNRET=0
else
debug "Debian version is less than 10"
FNRET=1
fi
else
debug "Current OS is not Debian."
FNRET=2
@ -38,14 +45,21 @@ is_debian_ge_10()
is_debian_ge_9()
{
# For debian11
DEBIAN11CODENAME="bullseye"
if [ -r /etc/debian_version ]; then
if [ $(cat /etc/debian_version | awk -F"." '{print $1}') -ge 9 ]; then
debug "Debian version is greater than or equal to 9"
FNRET=0
else
debug "Debian version is less than 9"
FNRET=1
fi
if [ $(grep -cw "^$DEBIAN11CODENAME" /etc/debian_version) -eq 1 ]; then
debug "Debian version is greater than or equal to 10"
FNRET=0
return
fi
if [ $(cat /etc/debian_version | awk -F"." '{print $1}') -ge 9 ]; then
debug "Debian version is greater than or equal to 9"
FNRET=0
else
debug "Debian version is less than 9"
FNRET=1
fi
else
debug "Current OS is not Debian."
FNRET=2