Skip to content

Instantly share code, notes, and snippets.

@drewkerrigan
Created May 29, 2012 15:35
Show Gist options
  • Save drewkerrigan/2829115 to your computer and use it in GitHub Desktop.
Save drewkerrigan/2829115 to your computer and use it in GitHub Desktop.
#!/bin/bash
moss_access_key="<your_access_key>"
moss_secret_key="<your_secret_key>"
method="PUT"
endtime=$(date '+%s')
endtime=$((endtime + 1800))
nowtime=$(date '+%s')
mv stats.txt{,.bak}
mv filelist.txt{,.bak}
while [ $nowtime -lt $endtime ]
do
header_date=$(date +'%a, %d %b %Y %T %Z')
filenumber=$(($RANDOM % 100))
filename=`(echo "$RANDOM" | md5sum | head -c 12)`
path="/test/$filename"
auth_string="$method\n\napplication/octet-stream\n$header_date\n$path"
hash_code=`echo -n -e "$auth_string" | openssl dgst -binary -sha1 -hmac $moss_secret_key | base64`
auth_header="AWS $moss_access_key:$hash_code"
result=`curl -o /dev/null -w "time: "%{time_total}" status: "%{http_code} -k -s -H "Authorization: $auth_header" -H "Content-Type: application/octet-stream" -H "Date: $header_date" -XPUT --proxy1.0 http
://10.80.83.68:8077 http://sl.basho.com:80$path -T ./files/$filenumber`
echo $result >> stats.txt
echo "$filename" >> filelist.txt
nowtime=$(date '+%s')
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment