-
Notifications
You must be signed in to change notification settings - Fork 8
/
ingestcollectionchecksum
executable file
·40 lines (35 loc) · 1.15 KB
/
ingestcollectionchecksum
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
#!/usr/bin/env bash
# ingestcollectionchecksum
# This script imports already existing information to the database (read back
# checksums). It can be run either on individual files or on directories
# containing multiple files.
SCRIPTDIR=$(dirname $(command -v "${0}"))
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ; }
if [ -z "${PREMIS_NAME}" ] || [ "${PREMIS_DB}" != "Y" ] ; then
echo "Please configure database options in mmconfig. Exiting"
fi
user_input="${*}"
if [ -d "${1}" ] ; then
cd "${1}"
for i in *.md5 ; do
db_source="${1}"/"${i}"
db_fixity=$(cat "${i}")
MEDIA_ID=$(basename "${i}" | cut -d'_' -f1)
eventType="ingest"
echo "Ingesting ${i}"
_report_to_db
_eventoutcome_update
_report_fixity_db
done
elif [ -f "${1}" ] ; then
db_fixity=$(cat "${1}")
db_source="${1}"
MEDIA_ID=$(basename "${db_source}" | cut -d'_' -f1 | cut -d'.' -f1)
eventType="ingest"
echo "Ingesting ${1}"
_report_to_db
_eventoutcome_update
_report_fixity_db
else
echo "Please use a valid directory for input. Exiting" && exit 1
fi