Guest User

Untitled

a guest
Jan 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Written by W3ird_N3rd. Any bugs are my fault. I take no responsibility. Please complain to your God if something goes wrong.
  4. #This script is public domain. Don't come to me complaining about copyright, I don't want it
  5.  
  6. if [ "$1" == "" ] || [ "$2" == "" ]
  7. then
  8. echo "No arguments!"
  9. echo "Usage: hdburnin sourceFILE destDIR [quiet]"
  10. exit
  11. fi
  12.  
  13. filename=$(basename $1)
  14. destfile="$2/$filename"
  15. NUMBER=0
  16.  
  17. echo "Destfile is $destfile"
  18. #copy destfile
  19. cp "$1" "$2"
  20. #check destfile
  21. md5=$(md5sum $destfile)
  22. sumresult=$md5
  23.  
  24. echo "Destfile sum: $md5"
  25.  
  26. while [ "$sumresult" == "$md5" ]
  27. do
  28. #copy file
  29. begincopy=$(date +%s)
  30. cp "$1" "$2"
  31. endcopy=$(date +%s)
  32. copytime=$[$endcopy - $begincopy]
  33. #checksum file
  34. beginsum=$(date +%s)
  35. sumresult=$(md5sum $destfile)
  36. endsum=$(date +%s)
  37. sumtime=$[$endsum - $beginsum]
  38. NUMBER=$[$NUMBER + 1]
  39. if [ ! $3 ] && [ "$sumresult" == "$md5" ]
  40. then
  41. echo "Test #$NUMBER. Sum OK. Copy took $copytime seconds, checksum took $sumtime seconds."
  42. fi
  43. done
  44. #This portion would never be reached normally as the while runs indefinitely as long as checksums are ok
  45. echo "$md5 was expected"
  46. echo ""
  47. echo "$sumresult was the result"
  48. echo "FAILED AFTER $NUMBER TESTS. CHECKSUM FAILURE. PLEASE SUE YOUR HARDWARE VENDOR."
Add Comment
Please, Sign In to add comment