From 436d3793334f25ba0eb71f13a381511c9bfd29ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=2ES?= Date: Thu, 4 Apr 2019 15:55:25 +0200 Subject: [PATCH] Loop version of check-incs using test -d --- check-incs.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/check-incs.sh b/check-incs.sh index 3cd6c36..83a4117 100644 --- a/check-incs.sh +++ b/check-incs.sh @@ -1,4 +1,5 @@ #!/bin/sh +shopt -s nullglob EVOBACKUP_CONFIGS="/etc/evobackup/*" @@ -12,10 +13,10 @@ relative_date() { echo ${past_date} } inc_exists() { - ls -d /backup/incs/$1 > /dev/null 2>&1 + test -d /backup/incs/$1 } jail_exists() { - ls -d /backup/jails/$1 > /dev/null 2>&1 + test -d /backup/jails/$1 } # default return value is 0 (succes) rc=0 @@ -34,11 +35,13 @@ for file in ${EVOBACKUP_CONFIGS}; do inc_age=$(date --date "${inc_date}" +%s) # check if the configuration changed after the inc date if [ $jail_config_age -lt $inc_age ]; then + for inc in ${jail_name}/${inc_date}*; do # Error if inc is not found - if ! inc_exists ${jail_name}/${inc_date}*; then + if ! inc_exists ${inc}; then echo "ERROR: inc is missing \`${jail_name}/${inc_date}'" >&2 rc=1 fi + done else echo "INFO: no inc expected for ${inc_date} \`${jail_name}'" fi