try heredoc

This commit is contained in:
surtur 2020-05-10 09:52:56 +02:00
parent df751806b8
commit 780037a9b4
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

@ -123,19 +123,39 @@ steps:
commands: commands:
- ls -la /run/cache - ls -la /run/cache
- export FILE_TO_UPLOAD=/run/cache/archives/$(ls /run/cache/archives | head -1) - >
- export MIME_TYPE=text/plain cat &gt ul_me << EOF
- export SHA1_OF_FILE=$(openssl dgst -sha1 $FILE_TO_UPLOAD | awk '{print $2;}') #!/bin/bash
- export apiUrl=$(curl -s 'https://api.backblazeb2.com/b2api/v2/b2_authorize_account' -u "$B2_KEY_ID:$B2_KEY" | python -c "import sys, json; print (json.load(sys.stdin)['apiUrl'])")
- echo $apiUrl $B2_BUCKET_ID $B2_KEY_ID $B2_KEY $B2_TOKEN echo backblaze b2 custom uploader
- export UPLOAD_URL=$(curl -H 'Authorization:$B2_TOKEN' -d '{"bucketId":"$B2_BUCKET_ID"}' $apiUrl/b2api/v2/b2_get_upload_url | python -c "import sys, json; print (json.load(sys.stdin)['uploadUrl'])")
- echo $UPLOAD_URL export FILE_TO_UPLOAD=/run/cache/archives/$(ls /run/cache/archives | head -1)
- curl -H "Authorization:$B2_TOKEN" -H "X-Bz-File-Name:$FILE_TO_UPLOAD" -H "Content-Type:$MIME_TYPE" -H "X-Bz-Content-Sha1:$SHA1_OF_FILE" -H "X-Bz-Info-Author:${DRONE_COMMIT_AUTHOR}" --data-binary "@$FILE_TO_UPLOAD" $UPLOAD_URL export FILE_TO_UPLOAD=${1}
- export FILE_TO_UPLOAD=/run/cache/archives/$(ls /run/cache/archives | tail -1) export MIME_TYPE=${2}
- export MIME_TYPE=application/zstd export $B2_KEY_ID=${3}
- export SHA1_OF_FILE=$(openssl dgst -sha1 $FILE_TO_UPLOAD | awk '{print $2;}') export $B2_KEY=${4}
- curl -H "Authorization:$B2_TOKEN" -H "X-Bz-File-Name:$FILE_TO_UPLOAD" -H "Content-Type:$MIME_TYPE" -H "X-Bz-Content-Sha1:$SHA1_OF_FILE" -H "X-Bz-Info-Author:${DRONE_COMMIT_AUTHOR}" --data-binary "@$FILE_TO_UPLOAD" $UPLOAD_URL export $B2_BUCKET_ID=${5}
- cd export $B2_TOKEN=${6}
export SHA1_OF_FILE=$(openssl dgst -sha1 $FILE_TO_UPLOAD | awk '{print $2;}')
export apiUrl=$(curl -s 'https://api.backblazeb2.com/b2api/v2/b2_authorize_account' -u "$B2_KEY_ID:$B2_KEY" | python -c "import sys, json; print (json.load(sys.stdin)['apiUrl'])")
echo $apiUrl $B2_BUCKET_ID $B2_KEY_ID $B2_KEY $B2_TOKEN
export UPLOAD_URL=$(curl -s -H 'Authorization:$B2_TOKEN' -d '{"bucketId":"$B2_BUCKET_ID"}' $apiUrl/b2api/v2/b2_get_upload_url | python -c "import sys, json; print (json.load(sys.stdin)['uploadUrl'])")
curl -s -H "Authorization:$B2_TOKEN" -H "X-Bz-File-Name:$FILE_TO_UPLOAD" -H "Content-Type:$MIME_TYPE" -H "X-Bz-Content-Sha1:$SHA1_OF_FILE" -H "X-Bz-Info-Author:${DRONE_COMMIT_AUTHOR}" --data-binary "@$FILE_TO_UPLOAD" $UPLOAD_URL
echo "** done **"
- chmod +x ul_me
- ./ul_me "/run/cache/archives/$(ls /run/cache/archives | head -1)" "text/plain" "$B2_KEY_ID" "$B2_KEY" "$B2_BUCKET_ID" "$B2_TOKEN"
- ./ul_me "/run/cache/archives/$(ls /run/cache/archives | tail -1)" "application/zstd" "B2$KEY_ID" "$B2_KEY" "$B2_BUCKET_ID" "$B2_TOKEN"
# - export FILE_TO_UPLOAD=/run/cache/archives/$(ls /run/cache/archives | head -1)
# - export MIME_TYPE=text/plain
# - export SHA1_OF_FILE=$(openssl dgst -sha1 $FILE_TO_UPLOAD | awk '{print $2;}')
# - export apiUrl=$(curl -s 'https://api.backblazeb2.com/b2api/v2/b2_authorize_account' -u "$B2_KEY_ID:$B2_KEY" | python -c "import sys, json; print (json.load(sys.stdin)['apiUrl'])")
# - export UPLOAD_URL=$(curl -s -H 'Authorization:$B2_TOKEN' -d '{"bucketId":"$B2_BUCKET_ID"}' $apiUrl/b2api/v2/b2_get_upload_url | python -c "import sys, json; print (json.load(sys.stdin)['uploadUrl'])")
# - curl -s -H "Authorization:$B2_TOKEN" -H "X-Bz-File-Name:$FILE_TO_UPLOAD" -H "Content-Type:$MIME_TYPE" -H "X-Bz-Content-Sha1:$SHA1_OF_FILE" -H "X-Bz-Info-Author:${DRONE_COMMIT_AUTHOR}" --data-binary "@$FILE_TO_UPLOAD" $UPLOAD_URL
# - export FILE_TO_UPLOAD=/run/cache/archives/$(ls /run/cache/archives | tail -1)
# - export MIME_TYPE=application/zstd
# - export SHA1_OF_FILE=$(openssl dgst -sha1 $FILE_TO_UPLOAD | awk '{print $2;}')
# - curl -H "Authorization:$B2_TOKEN" -H "X-Bz-File-Name:$FILE_TO_UPLOAD" -H "Content-Type:$MIME_TYPE" -H "X-Bz-Content-Sha1:$SHA1_OF_FILE" -H "X-Bz-Info-Author:${DRONE_COMMIT_AUTHOR}" --data-binary "@$FILE_TO_UPLOAD" $UPLOAD_URL
volumes: volumes:
- name: cache - name: cache