From 08f4610aec5733bbddd3d1bf7110d80ca4a003a4 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 10 Jul 2014 12:12:16 -0400 Subject: [PATCH] Fix CURL error handling in FTP upload hook --- python_apps/airtime_analyzer/tools/ftp-upload-hook.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh b/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh index f5be38183..0174f9a07 100755 --- a/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh +++ b/python_apps/airtime_analyzer/tools/ftp-upload-hook.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/bash -xv post_file() { #kill process after 30 minutes (360*5=30 minutes) @@ -28,7 +28,9 @@ post_file() { api_key=$(awk -F "= " '/api_key/ {print $2}' $instance_conf_path) - until curl --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}" -F "full_path=${file_path}" + # -f is needed to make curl fail if there's an HTTP error code + # -L is needed to follow redirects! (just in case) + until curl -fL --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}" -F "full_path=${file_path}" do retry_count=$[$retry_count+1] if [ $retry_count -ge $max_retry ]; then