diff --git a/evocheck.sh b/evocheck.sh index 1af4599..a825350 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 ] && [ -n "${msg}" ] && 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 @@ -839,14 +843,8 @@ if [ -e /etc/debian_version ]; then fi 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 - if [[ ${PIPESTATUS[2]} == 0 ]]; then - # There is at least one dir matching - echo 'IS_OLD_HOME_DIR FAILED!' - break - fi - done + find /home/ -maxdepth 1 -type d -nouser | grep -q '^' && echo 'IS_OLD_HOME_DIR FAILED!' + [ "${VERBOSE}" -eq 1 ] && find /home/ -maxdepth 1 -type d -nouser -exec stat -c "%n has owner %u resolved as %U" {} \; fi fi