#!/bin/sh # # verify-checksums.sh - create checksums of files - crc32, md5 and sha256 are created with 2 indipendend tools (cfv and md5deep) # # Use ./verify-checksums.sh --help for help # # Developed by Lubomir Host 'rajo' # All rights reserved. # # Changelog: # 2011-07-11 - created # # Installation on Debian: apt-get install cfv md5deep # $Id$ MEDIA="$HOME/media" DIRS="foto video" # subdirs of $MEDIA for verification export HOME="$MEDIA" # search for ~/.cfvrc in $MEDIA min_year=2004 max_year=`date '+%Y'` date=`date +'%Y-%m-%d_%H%M%S'` CFV="`which cfv`" HASHDEEP="`which hashdeep`" #echo "$CFV" "$HASHDEEP" verify_cfv ( ) { # {{{ [ ! -z "$CFV" ] && [ -x "$CFV" ] || return 1 dir=$1 year=$2 output="$MEDIA/$dir/$year-cfv-checksum.csv" cd "$MEDIA/$dir" if [ -f "$output" ]; then # test mode "$CFV" -rr -M -u -f"$output" -p "$year" else # create mode "$CFV" -C -t csv -f"$output" "$year" fi } # }}} verify_hashdeep ( ) { # {{{ [ ! -z "$HASHDEEP" ] && [ -x "$HASHDEEP" ] || return 1 dir=$1 year=$2 output="$MEDIA/$dir/$year-hashdeep-checksum.csv" cd "$MEDIA/$dir" if [ -f "$output" ]; then # test mode "$HASHDEEP" -a -r -k "$output" "$year" else # create mode "$HASHDEEP" -r "$year" > "$output" fi } # }}} if [ -z "$CFV" -o ! -x "$CFV" ]; then echo "Executable 'cfv' not found, check http://freshmeat.net/projects/cfv/" fi if [ -z "$HASHDEEP" -o ! -x "$HASHDEEP" ]; then echo "Executable 'hashdeep' not found, check http://sourceforge.net/projects/md5deep/" fi # parse options {{{ for opt in $*; do case $opt in --help) shift; mode=help; ;; --update) shift; mode=update; ;; *) ;; esac done # }}} # HELP {{{ if [ "x$mode" = "xhelp" ]; then cat <