#!/bin/bash #Copyright 2002 William Stearns #Released under the GPL. if [ -z "$1" ]; then echo "Usage: $0 Filename_to_pull_raw_hashes_from" echo Exiting. exit 1 fi HashFile="${1}" HashCount=`cat "$HashFile" | wc -l` NumBlocks=$(( ($HashCount + 19) / 20 )) echo "Processing $HashCount lines in $HashFile in $NumBlocks blocks of 20" CleanLines () { #case each line on "key:" or razor-cache format or straight hash while read OneLine ; do case "$OneLine" in '') echo NullLine >>/dev/stderr ;; .) : ;; key:*) #key line echo "$OneLine" | sed -e 's@&[^&]*$@@' -e 's/$/\&action:lookup/' ;; [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/key:*) #razor-cache format line echo "$OneLine" | sed -e 's@^[^/]*/@@' -e 's@&[^&]*$@@' -e 's/$/\&action:lookup/' ;; [0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) #raw hash echo "$OneLine" | sed -e 's/^/key:/' -e 's/$/\&action:lookup/' || echo Failed "$OneLine" >>/dev/stderr ;; *) echo Unhandled: "$OneLine" >>/dev/stderr ;; esac done } #head --lines=3 "$HashFile" | CleanLines #echo Exiting..... #exit for X in `seq 1 $NumBlocks` ; do ( head --lines=$(( $X * 20 )) "$HashFile" | \ tail --lines=20 | \ CleanLines ; echo '.' ) | \ nc localhost 2702 done #Last minute check of the entire file. cat "$HashFile" | \ ( CleanLines ; echo '.' ) | \ nc localhost 2702