From 9325d87b4e13ea3955fd6f72c56c9ebe3fe0ec3d Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 21 Nov 2018 09:01:16 +0100 Subject: [PATCH] firmware: finalise mtree health check Not what I was expecting from a base tool like mtree... * Missing files are not seen as an error condition, so remove our ignored files (they show up as nonexistent) and then count how many files are missing. If there is at least a missing file show the output and don't say everything is swell. * Since we prefilter MTREE_OUT on a real error just show the output since it's likely there's an error to see. --- src/opnsense/scripts/firmware/health.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/opnsense/scripts/firmware/health.sh b/src/opnsense/scripts/firmware/health.sh index 90a8438b6..ab3e4ab2b 100755 --- a/src/opnsense/scripts/firmware/health.sh +++ b/src/opnsense/scripts/firmware/health.sh @@ -86,12 +86,19 @@ set_check() MTREE_OUT=$(${MTREE} -X ${TMPFILE} < ${FILE} 2>&1) MTREE_RET=${?} + MTREE_OUT=$(echo "${MTREE_OUT}" | grep -Fvx "${GREP_PATTERNS}") + MTREE_MIA=$(echo "${MTREE_OUT}" | grep -c ' missing$') + if [ ${MTREE_RET} -eq 0 ]; then - echo "No problems detected." >> ${PKG_PROGRESS_FILE} 2>&1 + if [ "${MTREE_MIA}" = "0" ]; then + echo "No problems detected." >> ${PKG_PROGRESS_FILE} 2>&1 + else + echo "Missing files: ${MTREE_MIA}" >> ${PKG_PROGRESS_FILE} 2>&1 + echo "${MTREE_OUT}" >> ${PKG_PROGRESS_FILE} 2>&1 + fi else echo "Error ${MTREE_RET} ocurred." >> ${PKG_PROGRESS_FILE} 2>&1 - echo -n "${MTREE_OUT}" | grep -Fvx "${GREP_PATTERNS}" | \ - >> ${PKG_PROGRESS_FILE} 2>&1 + echo "${MTREE_OUT}" >> ${PKG_PROGRESS_FILE} 2>&1 fi rm ${TMPFILE}