Skip to content

Commit

Permalink
script that creates checksums for contents of LTO tape
Browse files Browse the repository at this point in the history
  • Loading branch information
dinahhandel committed Mar 29, 2016
1 parent 3463786 commit aac1c7a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions collectionchecksum
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit aac1c7a

Please sign in to comment.