Skip to content

Commit

Permalink
Updated direct write output updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
ladar committed Nov 3, 2023
1 parent 1245f35 commit 152fad6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions res/scripts/direct.sh
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,13 @@ function upload_box() {
DEFAULT_ARCH="true"
fi

WRITEOUT="\nFILE: $FILENAME\nREPO: $ORG/$BOX\nCODE: %{http_code}\nIP: %{remote_ip}\nBYTES: %{size_upload}\nRATE: %{speed_upload}\nTOTAL TIME: %{time_total}\n%{onerror}ERROR: %{errormsg}\n"

UPLOAD_FILE_WRITEOUT="\nFILE: $FILENAME\nREPO: $ORG/$BOX\nCODE: %{http_code}\nIP: %{remote_ip}\nBYTES: %{size_upload}\nRATE: %{speed_upload}\nTOTAL TIME: %{time_total}\n%{onerror}ERROR: %{errormsg}\n"
UPLOAD_CALLBACK_WRITEOUT="%{onerror}FILE: $FILENAME\nREPO: $ORG/$BOX\nCODE: %{http_code}\nIP: %{remote_ip}\nBYTES: %{size_upload}\nRATE: %{speed_upload}\nTOTAL TIME: %{time_total}\nERROR: %{errormsg}\n"

if [ "$(${CURL} -so /dev/null --write-out "%{onerror}" https://lavabit.com 2>&1)" ] || \
[ "$(${CURL} -so /dev/null --write-out "%{errormsg}" https://lavabit.com 2>&1)" ]then
WRITEOUT="\nFILE: $FILENAME\nREPO: $ORG/$BOX\nCODE: %{http_code}\nIP: %{remote_ip}\nBYTES: %{size_upload}\nRATE: %{speed_upload}\nTOTAL TIME: %{time_total}\n"
[ "$(${CURL} -so /dev/null --write-out "%{errormsg}" https://lavabit.com 2>&1)" ]; then
UPLOAD_FILE_WRITEOUT="\nFILE: $FILENAME\nREPO: $ORG/$BOX\nCODE: %{http_code}\nIP: %{remote_ip}\nBYTES: %{size_upload}\nRATE: %{speed_upload}\nTOTAL TIME: %{time_total}\n"
UPLOAD_CALLBACK_WRITEOUT="%{onerror}FILE: $FILENAME\nREPO: $ORG/$BOX\nCODE: %{http_code}\nIP: %{remote_ip}\nBYTES: %{size_upload}\nRATE: %{speed_upload}\nTOTAL TIME: %{time_total}\nERROR: %{errormsg}\n"
fi

# Checks whether the version exists already, and creates it if necessary.
Expand Down Expand Up @@ -390,7 +392,7 @@ function upload_box() {

retry ${CURL} --tlsv1.2 --silent --retry 4 --retry-delay 2 --max-time 7200 --request PUT --fail \
--speed-time 60 --speed-limit 1024 --expect100-timeout 7200 \
--write-out "$WRITEOUT" \
--write-out "$UPLOAD_FILE_WRITEOUT" \
--header "Connection: keep-alive" --upload-file "$FILEPATH" "$UPLOAD_PATH"

RESULT=$?
Expand All @@ -402,11 +404,11 @@ function upload_box() {
# Submit the callback twice. hopefully this will reduce the number of boxes without valid download URLs.
${CURL} --tlsv1.2 --silent --retry 4 --retry-delay 2 --max-time 180 --request PUT --fail \
--output "/dev/null" --header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
--write-out "$WRITEOUT" \
--write-out "$UPLOAD_CALLBACK_WRITEOUT" \
"$UPLOAD_CALLBACK" || \
{ sleep 16 ; ${CURL} --tlsv1.2 --silent --retry 4 --retry-delay 2 --max-time 180 --request PUT --fail \
--output "/dev/null" --header "Authorization: Bearer $VAGRANT_CLOUD_TOKEN" \
--write-out "$WRITEOUT" \
--write-out "$UPLOAD_CALLBACK_WRITEOUT" \
"$UPLOAD_CALLBACK" ; } || \
{ printf "${T_BYEL} Upload failed. The callback returned an error. [ $ORG $BOX $PROVIDER $ARCH $VERSION / RESULT = $RESULT ]${T_RESET}\n" >&2 ; exit 1 ; }

Expand Down

0 comments on commit 152fad6

Please sign in to comment.