#!/bin/sh
#
# Script for obtaining md5 and file information of all
# data in a given directory
#
# By C.Kronberg <smil@agleia.de>
# (10/2003)

echo " "
echo "Where are the files for fingerprinting are located?"
echo "Please give the absolute path:"
echo " "

read path
cd $path

echo "Where shall I write my results to? Please enter a"
echo "filename (with absolute path):"
echo " "

read resultfile
echo "" >$resultfile

MD5Prog=/usr/local/bin/md5deep
SHA256Prog=/usr/local/bin/sha256deep
TIGERProg=/usr/local/bin/tigerdeep


#List=`du -a |grep -v ^/proc | cut -d "/" -f 2-`
find . -type f -print | cut -d "." -f 2- | grep -v ^/proc  >/tmp/lll

while read -r i 
do
  md5=`$MD5Prog ".${i}" | cut -d " " -f 1`
  sha256=`$SHA256Prog ".${i}" | cut -d " " -f 1`
  tiger=`$TIGERProg ".${i}" | cut -d " " -f 1`

  link=`ls -l ".${i}" | cut -c 1`
  if [ x$link = "xl" ]; then
     perm="lrwxrwxrwx"
     dir=`ls -l .$i | cut -d ">" -f 2`
     size=" - "
     desc="symbolic link to $dir"
  else
    size=`wc -c ".${i}" | cut -d "." -f 1`
    perm=`ls -l ".${i}" | cut -d " " -f 1`
    filet=`file ".${i}" | cut -d ":" -f 2-`
    desc=" "
  fi
  # print to file
  echo "${md5}|${sha256}|${tiger}|.${i}|${size}|${perm}|${filet}|${desc}" >>$resultfile
done </tmp/lll

exit

