Modify 2.1 for compatibility.

This commit is contained in:
Samson-W 2019-08-01 04:46:59 +08:00
parent c5e9839e97
commit 1fa5bdd149

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# harbian audit Debian 7/8/9 Hardening # harbian audit Debian 7/8/9 or CentOS Hardening
# Modify by: Samson-W (sccxboy@gmail.com) # Modify by: Samson-W (sccxboy@gmail.com)
# #
@ -17,7 +17,6 @@ HARDENING_LEVEL=2
# Quick factoring as many script use the same logic # Quick factoring as many script use the same logic
PARTITION="/tmp" PARTITION="/tmp"
TMPMOUNTNAME="tmp.mount" TMPMOUNTNAME="tmp.mount"
TMPMOUNTO="/usr/share/systemd/tmp.mount"
# This function will be called if the script status is on enabled / audit mode # This function will be called if the script status is on enabled / audit mode
audit () { audit () {
@ -37,25 +36,20 @@ audit () {
fi fi
else else
warn "$PARTITION is not partition in /etc/fstab, check tmp.mount service" warn "$PARTITION is not partition in /etc/fstab, check tmp.mount service"
if [ -e $TMPMOUNTO ]; then if [ $(systemctl | grep -c "tmp.mount[[:space:]]*loaded[[:space:]]active[[:space:]]mounted") -eq 1 ]; then
if [ $(systemctl | grep -c "tmp.mount[[:space:]]*loaded[[:space:]]active[[:space:]]mounted") -eq 1 ]; then ok "$TMPMOUNTNAME service is active!"
ok "$TMPMOUNTNAME service is active!" is_mounted "$PARTITION"
is_mounted "$PARTITION" if [ $FNRET -gt 0 ]; then
if [ $FNRET -gt 0 ]; then warn "$PARTITION is not mounted"
warn "$PARTITION is not mounted" FNRET=3
FNRET=3 else
else ok "$PARTITION is mounted"
ok "$PARTITION is mounted" FNRET=0
FNRET=0
fi
else
crit "$TMPMOUNTNAME service is not active!"
FNRET=4
fi fi
else else
crit "$TMPMOUNTO is not exist!" crit "$TMPMOUNTNAME service is not active!"
FNRET=1 FNRET=4
fi fi
fi fi
} }
@ -72,7 +66,7 @@ apply () {
$SUDO_CMD systemctl daemon-reload $SUDO_CMD systemctl daemon-reload
$SUDO_CMD systemctl start "$TMPMOUNTNAME" $SUDO_CMD systemctl start "$TMPMOUNTNAME"
elif [ $FNRET = 4 ]; then elif [ $FNRET = 4 ]; then
$SUDO_CMD systemctl enable "$TMPMOUNTO" $SUDO_CMD systemctl enable "$TMPMOUNTNAME"
$SUDO_CMD systemctl daemon-reload $SUDO_CMD systemctl daemon-reload
$SUDO_CMD systemctl start "$TMPMOUNTNAME" $SUDO_CMD systemctl start "$TMPMOUNTNAME"
fi fi