#!/bin/sh

if [ $# -lt 1 ] ; then
  echo "Usage: tc-image-md5sum <osimg>"
  exit 1
fi

CREATECACHE=/home/tc/bin/tc-create-cache
FASTCAT=/home/tc/bin/tc-fastcat

osimg=$1
cache_file=/tmp/fastcat.cache
blk_size=4096
img_size=`stat -c %s "$osimg"`

$CREATECACHE $osimg $img_size $cache_file $blk_size
ret=$?
if [ $ret -ne 0 ] ; then
  echo "create cache failed"
  exit $ret
fi

$FASTCAT $osimg $img_size $cache_file $blk_size | md5sum

