|
|
@@ -7,13 +7,15 @@ TIMEOUT=${2:?no timeout provided} |
|
|
|
LOG=/tmp/ensure_file_$(echo ${TARGET_FILE} | tr '/' '_').log |
|
|
|
|
|
|
|
start=$(date +%s) |
|
|
|
while [[ ! -f ${TARGET_FILE} && $(expr $(date +%s) - ${start}) -le ${TIMEOUT} ]] ; do |
|
|
|
echo "$(date): $0: waiting for target file to exist ${TARGET_FILE} (will timeout after ${TIMEOUT} seconds)" | tee -a ${LOG} |
|
|
|
while [[ ! -s ${TARGET_FILE} && $(expr $(date +%s) - ${start}) -le ${TIMEOUT} ]] ; do |
|
|
|
echo "$(date): $0: waiting for target file to exist with some content ${TARGET_FILE} (will timeout after ${TIMEOUT} seconds)" \ |
|
|
|
| tee -a ${LOG} |
|
|
|
sleep 1s |
|
|
|
done |
|
|
|
|
|
|
|
if [[ ! -f ${TARGET_FILE} ]] ; then |
|
|
|
echo "target file did not get created: ${TARGET_FILE} (timeout after ${TIMEOUT} seconds)" | tee -a ${LOG} |
|
|
|
if [[ ! -s ${TARGET_FILE} ]] ; then |
|
|
|
echo "target file did not get created or is empty: ${TARGET_FILE} (timeout after ${TIMEOUT} seconds)" | tee -a ${LOG} |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
echo "target file has been created: ${TARGET_FILE}" | tee -a ${LOG} |
|
|
|
|
|
|
|
echo "target file has been created: ${TARGET_FILE}" | tee -a ${LOG} |