From 2ad65f4512c0751076630855e61e6f9d0e2dd81f Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 11 Feb 2018 13:07:54 +0100 Subject: [PATCH] Improve file handling in check_config Signed-off-by: Knut Ahlers --- bin/check_config | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/check_config b/bin/check_config index 26f4131..7f8b657 100755 --- a/bin/check_config +++ b/bin/check_config @@ -31,7 +31,10 @@ STAT_PARM="-c %Y" NEED_UPDATE=() # Check repos for updates for REPO in ${REPOS[@]}; do - if [ $(( $(date +%s) - $(stat ${STAT_PARM} .cfg/${REPO}/FETCH_HEAD) )) -gt ${FETCH_INTERVAL} ] || [ $(wc -c ~/.cfg/${REPO}/FETCH_HEAD | cut -d' ' -f1) -eq 0 ]; then + LAST_FETCH=0 + [ -f ~/.cfg/${REPO}/FETCH_HEAD ] && LAST_FETCH=$(stat ${STAT_PARM} ~/.cfg/${REPO}/FETCH_HEAD) + if [ $(( $(date +%s) - ${LAST_FETCH} )) -gt ${FETCH_INTERVAL} ] || \ + [ $(wc -c ~/.cfg/${REPO}/FETCH_HEAD | cut -d' ' -f1) -eq 0 ]; then vault-sshadd ${SSH_KEY} 2>&1 >/dev/null || { echo "Unable to load key ${SSH_KEY}"; exit 1; } gwrap fetch -q origin master fi