-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script that creates checksums for contents of LTO tape
- Loading branch information
1 parent
3463786
commit aac1c7a
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|