From aac1c7a386cedca9771465f1496ab1636dd71541 Mon Sep 17 00:00:00 2001 From: dinahhandel Date: Tue, 29 Mar 2016 10:59:24 -0400 Subject: [PATCH] script that creates checksums for contents of LTO tape --- collectionchecksum | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 collectionchecksum diff --git a/collectionchecksum b/collectionchecksum new file mode 100755 index 0000000..6f44513 --- /dev/null +++ b/collectionchecksum @@ -0,0 +1,34 @@ +#!/bin/bash +#this script will create checksums of metadata files, concatinate checksum.md5 files, and append to one large checksum file for each directory +#this script presumes a highly specific directory structure based on CUNY TV's Archival Information Package directory structure. + +_maketemp(){ + mktemp -q "/tmp/$(basename "${0}").XXXXXX" + if [ "${?}" -ne 0 ]; then + echo "${0}: Can't create temp file, exiting..." + _writeerrorlog "_maketemp" "was unable to create the temp file, so the script had to exit." + exit 1 + fi +} + +while [ "${*}" != "" ] ; do + INPUT="${1}" + TAPECHECKSUMFILE="${INPUT}/tapechecksum.md5" + TEMPCHECKSUMFILE=$(_maketemp) + cd "${INPUT}" + + #loop through the directories, find the checksum files, cat them together, and also sed to add the media ids + for CHECKSUMFILES in $(find ${INPUT} -maxdepth 3 -mindepth 3 -type f -iname "checksum.md5"); do + PACKAGE=$(basename $(dirname $(dirname "${CHECKSUMFILES}"))) + echo "${PACKAGE}" + cat "${CHECKSUMFILES}" | sed "s| ./| ./${PACKAGE}/|g" >> "${TEMPCHECKSUMFILE}" + done + + #create md5 checksums for all of the files in the metadata directory + md5deep -rel ./*/metadata >> "${TEMPCHECKSUMFILE}" + + sort -k2 "${TEMPCHECKSUMFILE}" >> "${TAPECHECKSUMFILE}" + + shift +done +