Fix CURL error handling in FTP upload hook

This commit is contained in:
Albert Santoni 2014-07-10 12:12:16 -04:00
parent 52b8f3af87
commit 08f4610aec

View file

@ -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