Fix some bugs.

This commit is contained in:
samson 2018-12-05 16:28:34 +08:00
parent d45ddb82f7
commit 7433811fa0
2 changed files with 75 additions and 55 deletions

View File

@ -19,6 +19,11 @@ GROUP='adm'
# This function will be called if the script status is on enabled / audit mode
audit () {
does_file_exist "$SYSLOG_BASEDIR/syslog-ng.conf"
if [ $FNRET != 0 ]; then
warn "$SYSLOG_BASEDIR/syslog-ng.conf is not exist! "
FNRET=1
else
FILES=$(grep "file(" $SYSLOG_BASEDIR/syslog-ng.conf | grep '"' | cut -d'"' -f 2)
for FILE in $FILES; do
does_file_exist $FILE
@ -39,10 +44,15 @@ audit () {
fi
fi
done
fi
}
# This function will be called if the script status is on enabled mode
apply () {
if [ $FNRET = 1 ]; then
warn "$SYSLOG_BASEDIR/syslog-ng.conf is not exist! "
else
FILES=$(grep "file(" $SYSLOG_BASEDIR/syslog-ng.conf | grep '"' | cut -d'"' -f 2)
for FILE in $FILES; do
does_file_exist $FILE
if [ $FNRET != 0 ]; then
@ -64,6 +74,7 @@ apply () {
chmod 0$PERMISSIONS $FILE
fi
done
fi
}
# This function will create the config file for this check with default values

View File

@ -17,6 +17,7 @@ PATTERN='^destination.*(tcp|udp)[[:space:]]*\([[:space:]]*\".*\"[[:space:]]*\)'
# This function will be called if the script status is on enabled / audit mode
audit () {
if [ -d "$SYSLOG_BASEDIR" ]; then
FILES="$SYSLOG_BASEDIR/syslog-ng.conf $SYSLOG_BASEDIR/conf.d/*"
does_pattern_exist_in_file "$FILES" "$PATTERN"
if [ $FNRET != 0 ]; then
@ -24,10 +25,17 @@ audit () {
else
ok "$PATTERN is present in $FILES"
fi
else
warn "$SYSLOG_BASEDIR is not exist!"
FNRET=1
fi
}
# This function will be called if the script status is on enabled mode
apply () {
if [ $FNRET = 1 ]; then
warn "$SYSLOG_BASEDIR is not exist!"
else
FILES="$SYSLOG_BASEDIR/syslog-ng.conf $SYSLOG_BASEDIR/conf.d/*"
does_pattern_exist_in_file "$FILES" "$PATTERN"
if [ $FNRET != 0 ]; then
@ -35,6 +43,7 @@ apply () {
else
ok "$PATTERN is present in $FILES"
fi
fi
}
# This function will create the config file for this check with default values