Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

crc check

By: a guest on Sep 25th, 2013  |  syntax: Bash  |  size: 0.73 KB  |  hits: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2. for exe in lynx wget grep awk ; do
  3.         if ! [ -x "$(which ${exe})" ] ; then
  4.                 echo "Please install '${exe}'!"
  5.                 exit 1
  6.         fi
  7. done
  8. CRCSUM="$1"
  9. if [ "$CRCSUM" = "" ] ; then
  10.         echo "No CRC checksum specified!"
  11.         echo "Usage: $0 <crc>"
  12.         exit 1
  13. fi
  14. OUTPUT="$(wget -O- -q http://www.srrdb.com/api/search/archive-crc:${CRCSUM} | sed 's/,/\n/g' | grep -E "release|resultsCount" | awk -F ":" '{print $NF}' | xargs echo | sed 's/ /;/')"
  15. if [ "$OUTPUT" = "0" ] ; then
  16.         echo "1;$CRCSUM;;"
  17.         exit 0
  18. else
  19.         RELEASE="$(awk -F ";" '{print $1}' <<< "$OUTPUT")"
  20. fi
  21. FILENAME="$(lynx -dump -nolist http://www.srrdb.com/release/details/${RELEASE} | grep -A 1 "Archived files" | tail -1 | awk '{print $1}')"
  22. echo "0;${CRCSUM};${FILENAME};${RELEASE}"