Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Written by W3ird_N3rd. Any bugs are my fault. I take no responsibility. Please complain to your God if something goes wrong.
- #This script is public domain. Don't come to me complaining about copyright, I don't want it
- if [ "$1" == "" ] || [ "$2" == "" ]
- then
- echo "No arguments!"
- echo "Usage: hdburnin sourceFILE destDIR [quiet]"
- exit
- fi
- filename=$(basename $1)
- destfile="$2/$filename"
- NUMBER=0
- echo "Destfile is $destfile"
- #copy destfile
- cp "$1" "$2"
- #check destfile
- md5=$(md5sum $destfile)
- sumresult=$md5
- echo "Destfile sum: $md5"
- while [ "$sumresult" == "$md5" ]
- do
- #copy file
- begincopy=$(date +%s)
- cp "$1" "$2"
- endcopy=$(date +%s)
- copytime=$[$endcopy - $begincopy]
- #checksum file
- beginsum=$(date +%s)
- sumresult=$(md5sum $destfile)
- endsum=$(date +%s)
- sumtime=$[$endsum - $beginsum]
- NUMBER=$[$NUMBER + 1]
- if [ ! $3 ] && [ "$sumresult" == "$md5" ]
- then
- echo "Test #$NUMBER. Sum OK. Copy took $copytime seconds, checksum took $sumtime seconds."
- fi
- done
- #This portion would never be reached normally as the while runs indefinitely as long as checksums are ok
- echo "$md5 was expected"
- echo ""
- echo "$sumresult was the result"
- echo "FAILED AFTER $NUMBER TESTS. CHECKSUM FAILURE. PLEASE SUE YOUR HARDWARE VENDOR."
Add Comment
Please, Sign In to add comment