From bb83598ff18f97068a4557dd68b8a6358ec93780 Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Thu, 9 Mar 2017 12:28:05 +0100 Subject: [PATCH] [DBS-1882] include redis.conf --- include/tests_databases | 48 +++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/include/tests_databases b/include/tests_databases index 2f37b3c8..bac849bd 100644 --- a/include/tests_databases +++ b/include/tests_databases @@ -41,7 +41,7 @@ if [ "${FIND}" = "" ]; then if [ ${DEBUG} -eq 1 ]; then Display --indent 2 --text "- MySQL process status" --result "${STATUS_NOT_FOUND}" --color WHITE --debug; fi LogText "Result: MySQL process not active" - else + else Display --indent 2 --text "- MySQL process status" --result "${STATUS_FOUND}" --color GREEN LogText "Result: MySQL is active" MYSQL_RUNNING=1 @@ -257,37 +257,39 @@ Register --test-no DBS-1882 --weight L --network NO --preqs-met "${PREQS_MET}" --skip-reason "${SKIPREASON}" --category security --description "Redis configuration file" if [ ${SKIPTEST} -eq 0 ]; then PATHS="${ROOTDIR}etc/redis ${ROOTDIR}usr/local/etc/redis" + ALLFILES=$(${LSBINARY} ${ROOTDIR}etc/redis.conf 2> /dev/null) FOUND=0 for DIR in ${PATHS}; do LogText "Action: scanning directory (${DIR}) for Redis configuration files" FILES=$(${LSBINARY} ${DIR}/*.conf 2> /dev/null) if [ ! -z "${FILES}" ]; then - for CONFFILE in ${FILES}; do - if FileIsReadable ${CONFFILE}; then - LogText "Action: checking if ${CONFFILE} is a Sentinel configuration file" - # Exclude Sentinel configuration file - FIND=$(${GREPBINARY} "^sentinel " ${CONFFILE}) - if [ ! -z "${FIND}" ]; then - LogText "Result: file is a Sentinel configuration file, skipping it" - else - LogText "Result: file is NOT a Sentinel configuration file. Now scanning if it is a Redis configuration file" - FIND=$(${GREPBINARY} "Redis" ${CONFFILE}) - if [ ! -z "${FIND}" ]; then - REDIS_CONFIGURATION_FILES="${REDIS_CONFIGURATION_FILES} ${CONFFILE}" - REDIS_CONFIGURATION_FOUND=1 - LogText "Result: found a Redis configuration file (${CONFFILE})" - else - LogText "Result: this file does not look like a Redis file (${CONFFILE})" - fi - fi - else - LogText "Could not read this file, so skipping it" - fi - done + ALLFILES="${ALLFILES} ${FILES}" else LogText "Result: no configuration files found in this directory" fi done + for CONFFILE in ${ALLFILES}; do + if FileIsReadable ${CONFFILE}; then + LogText "Action: checking if ${CONFFILE} is a Sentinel configuration file" + # Exclude Sentinel configuration file + FIND=$(${GREPBINARY} "^sentinel " ${CONFFILE}) + if [ ! -z "${FIND}" ]; then + LogText "Result: file is a Sentinel configuration file, skipping it" + else + LogText "Result: file is NOT a Sentinel configuration file. Now scanning if it is a Redis configuration file" + FIND=$(${GREPBINARY} "Redis" ${CONFFILE}) + if [ ! -z "${FIND}" ]; then + REDIS_CONFIGURATION_FILES="${REDIS_CONFIGURATION_FILES} ${CONFFILE}" + REDIS_CONFIGURATION_FOUND=1 + LogText "Result: found a Redis configuration file (${CONFFILE})" + else + LogText "Result: this file does not look like a Redis file (${CONFFILE})" + fi + fi + else + LogText "Could not read this file, so skipping it" + fi + done # Sort the list of discovered configuration files so we can make them unique REDIS_CONFIGURATION_FILES=$(echo ${REDIS_CONFIGURATION_FILES} | ${SEDBINARY} 's/^ //' | ${TRBINARY} ' ' '\n' | ${SORTBINARY} | ${UNIQBINARY} | ${TRBINARY} '\n' ' ') for FILE in ${REDIS_CONFIGURATION_FILES}; do