From 3cfa884a6fae30023a98e7e8a331664f2239bbde Mon Sep 17 00:00:00 2001 From: Victor LABORIE Date: Wed, 16 Jan 2019 16:53:53 +0100 Subject: [PATCH] Add a verbose function and use it for some checks (Fix #30) --- evocheck.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/evocheck.sh b/evocheck.sh index 1af4599..f9a8aeb 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -125,9 +125,17 @@ IS_NRPEDAEMON=1 IS_ALERTBOOT=1 IS_RSYNC=1 +# Verbose function +verbose() { + msg="${1:-$(cat /dev/stdin)}" + [ "${VERBOSE}" -eq 1 ] && echo "${msg}" +} + # Source configuration file test -f /etc/evocheck.cf && . /etc/evocheck.cf +VERBOSE="${VERBOSE:-0}" + # If --cron is passed, ignore some checks. if [ "$1" = "--cron" ]; then IS_KERNELUPTODATE=0 @@ -553,11 +561,7 @@ if [ -e /etc/debian_version ]; then percentage=$(python -c "print(int(round(float(${reservedBlockCount})/${blockCount}*100)))") if [ "$percentage" -lt 5 ]; then echo 'IS_TUNE2FS_M5 FAILED!' - # Set debug to 1, to displays which partitions has less than 5% - debug=0 - if [ "$debug" -eq 1 ]; then - echo "Partition $part has less than 5% reserved blocks!" - fi + verbose "Partition $part has less than 5% reserved blocks!" fi done fi @@ -840,7 +844,7 @@ if [ -e /etc/debian_version ]; then if [ "$IS_OLD_HOME_DIR" = 1 ]; then for dir in /home/*; do - stat -c "%n has owner %u resolved as %U" "$dir" | grep -v .bak | grep -q UNKNOWN + stat -c "%n has owner %u resolved as %U" "$dir" | grep -v .bak | grep UNKNOWN | verbose if [[ ${PIPESTATUS[2]} == 0 ]]; then # There is at least one dir matching echo 'IS_OLD_HOME_DIR FAILED!'