From 401d53da50f93d27e67995c82bd1dfd046130928 Mon Sep 17 00:00:00 2001 From: pratik Date: Wed, 22 Oct 2025 11:38:43 -0500 Subject: [PATCH] updates --- deploy-chunked.sh | 56 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/deploy-chunked.sh b/deploy-chunked.sh index d8bc217..223d8e8 100644 --- a/deploy-chunked.sh +++ b/deploy-chunked.sh @@ -45,6 +45,9 @@ CF_SKIP_SSL="false" # Use "true" for self-signed certificates POLL_INTERVAL=5 # seconds between status checks MAX_WAIT=600 # maximum wait time in seconds (10 minutes) +# Debug mode (set to "true" to see curl commands and responses) +DEBUG_MODE="false" + # Security configuration (optional) CERT_FILE="" # Path to client certificate file (leave empty to skip) KEY_FILE="" # Path to client private key file (leave empty to skip) @@ -147,14 +150,55 @@ echo "" ############################################################################# log_info "Step 1/5: Initializing upload session..." -INIT_RESPONSE=$(eval curl -s -X POST "$API_BASE/upload/init" \ - -H "Content-Type: application/json" \ - $CURL_OPTS \ - -d "'$CF_CONFIG'") +# Debug mode output +if [ "$DEBUG_MODE" = "true" ]; then + echo "DEBUG: API_BASE = $API_BASE" + echo "DEBUG: CURL_OPTS = $CURL_OPTS" + echo "DEBUG: Request JSON:" + echo "$CF_CONFIG" +fi -if [ $? -ne 0 ]; then - log_error "Failed to initialize upload session" +# Build the curl command +if [ -n "$CURL_OPTS" ]; then + if [ "$DEBUG_MODE" = "true" ]; then + INIT_RESPONSE=$(eval curl -v -X POST "$API_BASE/upload/init" \ + -H "Content-Type: application/json" \ + $CURL_OPTS \ + -d "'$CF_CONFIG'") + else + INIT_RESPONSE=$(eval curl -s -X POST "$API_BASE/upload/init" \ + -H "Content-Type: application/json" \ + $CURL_OPTS \ + -d "'$CF_CONFIG'") + fi +else + if [ "$DEBUG_MODE" = "true" ]; then + INIT_RESPONSE=$(curl -v -X POST "$API_BASE/upload/init" \ + -H "Content-Type: application/json" \ + -d "$CF_CONFIG") + else + INIT_RESPONSE=$(curl -s -X POST "$API_BASE/upload/init" \ + -H "Content-Type: application/json" \ + -d "$CF_CONFIG") + fi +fi + +CURL_EXIT_CODE=$? +if [ "$DEBUG_MODE" = "true" ]; then + echo "DEBUG: Curl exit code: $CURL_EXIT_CODE" + echo "DEBUG: Response:" echo "$INIT_RESPONSE" +fi + +if [ $CURL_EXIT_CODE -ne 0 ]; then + log_error "Failed to initialize upload session (curl exit code: $CURL_EXIT_CODE)" + echo "$INIT_RESPONSE" + exit 1 +fi + +# Debug output +if [ -z "$INIT_RESPONSE" ]; then + log_error "Empty response from server" exit 1 fi