Add a method to determine the system version for compatibility.

This commit is contained in:
Samson-W 2020-05-14 18:14:43 +08:00
parent 2e0435363c
commit 1570943606
2 changed files with 18 additions and 2 deletions

View File

@ -34,7 +34,7 @@ audit_debian () {
if [ $FNRET = 0 ]; then if [ $FNRET = 0 ]; then
ok "$PACKAGE is installed" ok "$PACKAGE is installed"
# Since Debian 10 (Buster), AppArmor is enabled by default. It's a system service # Since Debian 10 (Buster), AppArmor is enabled by default. It's a system service
is_debian_10 is_debian_ge_10
if [ $FNRET = 0 ]; then if [ $FNRET = 0 ]; then
is_service_active $SERVICENAME is_service_active $SERVICENAME
if [ $FNRET -eq 0 ]; then if [ $FNRET -eq 0 ]; then
@ -101,7 +101,7 @@ apply_debian () {
done done
elif [ $FNRET = 2 ]; then elif [ $FNRET = 2 ]; then
# Since Debian 10 (Buster), AppArmor is enabled by default. It's a system service # Since Debian 10 (Buster), AppArmor is enabled by default. It's a system service
is_debian_10 is_debian_ge_10
if [ $FNRET = 0 ]; then if [ $FNRET = 0 ]; then
warn "Start $SERVICENAME" warn "Start $SERVICENAME"
systemctl start $SERVICENAME systemctl start $SERVICENAME

View File

@ -20,6 +20,22 @@ is_centos_8()
fi fi
} }
is_debian_ge_10()
{
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
else
debug "Current OS is not Debian."
FNRET=2
fi
}
is_debian_ge_9() is_debian_ge_9()
{ {
if [ -r /etc/debian_version ]; then if [ -r /etc/debian_version ]; then