forked from amiaopensource/ltopers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verifylto
executable file
·77 lines (66 loc) · 2.32 KB
/
verifylto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
# verifylto
# This script creates a text document with a list of checksums that are
# generated after a readback. This is to ensure that all files transferred over
# correctly.
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ; }
TAPE_MOUNT_POINT="/Volumes"
TAPE_SERIAL_REGEX="^[A-Z0-9]{6}$"
_check_for_lto_index_dir
LTO_LOGS="${LTO_INDEX_DIR}"
TAPE_EJECT="N"
unset VERSION
if [[ $(dirname $(command -v "${0}")) = "/usr/local/bin" || $(dirname $(command -v "${0}")) = "${HOME}/.linuxbrew/bin" ]] ; then
VERSION=$(TMP=$(brew info ltopers | grep ".*\*$" | grep -Eo "/ltopers/.* \(") ; echo "${TMP:9:(${#TMP}-11)}")
fi
_usage(){
cat <<EOF
$(basename "${0}") ${VERSION}
This script creates a text document with a list of checksums that are
generated after a readback. This is to ensure that all files transferred over
correctly.
Usage: $(basename "${0}") -t [-e] | -h
-t tape serial
-e state yes (Y) or no (N) to ejecting the tape after write, default
is yes
-x use barcode label as tape serial (caveat: this is not standard)
-h display this help
EOF
}
OPTIND=1
while getopts ":t:e:xh" opt ; do
case "${opt}" in
t) TAPE_SERIAL="${OPTARG}" ;;
e) TAPE_EJECT="${OPTARG}" ;;
x) TAPE_SERIAL_REGEX="^[A-Z0-9]{6}(L[5-8]|M8)$" ;;
h) _usage ; exit 0 ;;
:) echo "Option -${OPTARG} requires an argument" ; exit 1 ;;
*) echo "Bad option -${OPTARG}" ; _usage ; exit 1 ;;
esac
done
shift "$((OPTIND-1))"
SOURCE_DIR="${1}"
if [[ "${PREMIS_DB}" = "Y" ]] ; then
_report_to_db
fi
if [[ ! $(echo "${TAPE_SERIAL}" | grep -E "${TAPE_SERIAL_REGEX}") ]] ; then
echo "${TAPE_SERIAL} is not valid."
exit 1
fi
TAPE_PATH="${TAPE_MOUNT_POINT}/${TAPE_SERIAL}"
_checkdir "${TAPE_PATH}"
VERIFYTIME=$(_get_iso8601_c)
READBACKDIR="${LTO_LOGS}/readback_checksums"
_mkdir2 "${READBACKDIR}"
find "${TAPE_PATH}" -type f ! -name .DS_Store -exec md5deep -rel "{}" >> "${READBACKDIR}/${TAPE_SERIAL}_ReadBack_checksum_${VERIFYTIME}.md5" \;
case "${TAPE_EJECT}" in
y|Y) umount "${TAPE_PATH}" ;;
*) echo "Done verifying but not ejecting ${TAPE_SERIAL}." ;;
esac
if [[ "${PREMIS_DB}" = "Y" ]] ; then
_eventoutcome_update
_report_schema_db
_report_fixity_db
_db_email_delivery "${SQL_ERROR_EMAIL_TO}"
fi