From e64ca0bb9fcda2e6d2c9be8fe592223b2c9aabb7 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Thu, 23 May 2019 13:57:29 +0200 Subject: [PATCH] Adding duration calculation Additional checks if image source is available --- piwirefresh.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/piwirefresh.sh b/piwirefresh.sh index b7f367a..7e0de8d 100755 --- a/piwirefresh.sh +++ b/piwirefresh.sh @@ -1,8 +1,24 @@ #!/bin/bash +mountedCheckFile="/home/network/Qbilder/photos/.mounted" catId=0 subCatId=1 +STARTTIME=$(date +%s) + +# -s : file exists and has a size greater than zero +if [ ! -s "$mountedCheckFile" ] ; then + echo "[refresh] Network not available (exists: $mountedCheckFile)" + exit 1; +fi + +# check if the file is really readable and contains text +mounted=$(cat "$mountedCheckFile" 2>>/dev/null) +if [ -z $mounted ] ; then + echo "[refresh] Network not available (content: $montedCheckFile)" + exit 1; +fi + if [ "$1" != "" ] && [ "$2" != "" ] then catId=$1 @@ -20,3 +36,6 @@ perl -w /root/script/piwigo_refresh.pl \ --privacy_level=4 \ --cat=${catId} \ --subcat=${subCatId} + +ENDTIME=$(date +%s) +echo "Refresh took: $((($ENDTIME - $STARTTIME)/60)) minutes"