Fix some bugs for CentOS8

This commit is contained in:
Samson-W 2019-12-28 02:32:49 +08:00
parent d98f6f1ca8
commit 816c101241
7 changed files with 30 additions and 8 deletions

View File

@ -27,7 +27,7 @@ audit () {
crit "Iptables/Ip6tables is not set rule!"
FNRET=1
else
ok "Ip4tables rules are set!"
ok "Iptables/Ip6tables rules are set!"
FNRET=0
fi
}

View File

@ -49,7 +49,7 @@ apply () {
ok "$PATTERN is present in $FILE"
elif [ $FNRET = 1 ]; then
warn "$PACKAGE is not installed, need install."
apt_install $PACKAGE
install_package $PACKAGE
elif [ $FNRET = 2 ]; then
warn "$FILE is not exist, please manual check."
elif [ $FNRET = 3 ]; then

View File

@ -56,7 +56,7 @@ apply () {
ok "$PATTERN is present in $FILE"
elif [ $FNRET = 1 ]; then
warn "$PACKAGE is not installed, need install."
apt_install $PACKAGE
install_package $PACKAGE
elif [ $FNRET = 2 ]; then
warn "$FILE is not exist, please manual check."
elif [ $FNRET = 3 ]; then

View File

@ -56,7 +56,7 @@ apply () {
ok "$PATTERN is present in $FILE"
elif [ $FNRET = 1 ]; then
warn "$PACKAGE is not installed, need install."
apt_install $PACKAGE
install_package $PACKAGE
elif [ $FNRET = 2 ]; then
warn "$FILE is not exist, please manual check."
elif [ $FNRET = 3 ]; then

View File

@ -56,7 +56,7 @@ apply () {
ok "$PATTERN is present in $FILE"
elif [ $FNRET = 1 ]; then
warn "$PACKAGE is not installed, need install."
apt_install $PACKAGE
install_package $PACKAGE
elif [ $FNRET = 2 ]; then
warn "$FILE is not exist, please manual check."
elif [ $FNRET = 3 ]; then

View File

@ -1,7 +1,7 @@
#!/bin/bash
#
# harbian audit 7/8/9 Hardening
# harbian audit 7/8/9 or CentOS8 Hardening
# Modify author:
# Samson-W (sccxboy@gmail.com)
#
@ -55,11 +55,19 @@ apply () {
elif [ $FNRET = 2 ]; then
warn "$OPTION is not present in $FILE, add it to $KEYWORD line, need to reboot the system after setting it"
sed -i "s;\(${KEYWORD}=\)\(\".*\)\(\"\);\1\2 ${OPTION}=${SETVAL}\3;" $FILE
/usr/sbin/update-grub2
if [ OS_RELEASE -eq 1 ]; then
usr/sbin/update-grub2
elif [ OS_RELEASE -eq 2 ]; then
grub2-mkconfig o /boot/grub2/grub.cfg
fi
elif [ $FNRET = 3 ]; then
warn "Parameter $OPTION is present but with the wrong value -- Fixing, need to reboot the system after setting it"
sed -i "s/${OPTION}=./${OPTION}=${SETVAL}/" $FILE
/usr/sbin/update-grub2
if [ OS_RELEASE -eq 1 ]; then
usr/sbin/update-grub2
elif [ OS_RELEASE -eq 2 ]; then
grub2-mkconfig o /boot/grub2/grub.cfg
fi
fi
}

View File

@ -565,6 +565,20 @@ yum_install()
FNRET=0
}
install_package()
{
if [ $OS_RELEASE -eq 1 ]; then
local PACKAGE=$1
apt_install $PACKAGE
elif [ $OS_RELEASE -eq 2 ]; then
local PACKAGE=$1
yum_install $PACKAGE
else
warn "Current OS is not support!"
fi
FNRET=0
}
#
# Returns if a package is installed
#