-
Notifications
You must be signed in to change notification settings - Fork 27
/
checksum2filemaker
executable file
·41 lines (38 loc) · 1.89 KB
/
checksum2filemaker
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
#!/bin/bash
# This script presumes that you've setup a filemaker database with Filemaker Server using a table called 'checksums' with fields according to the DFXML format.
VERSION=1.0
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;};
# check environment
if [ -z "${FILEMAKER_DB}" ] ; then
echo "The filemaker database must be set. Run mmconfig to set FILEMAKER_DB."
_writeerrorlog "checksum2filemaker" "The filemaker database was not set, so the script was unable to run."
exit 1
fi
if [ -z "${FILEMAKER_XML_URL}" ] ; then
echo "The filemaker xml path must be set. Run mmconfig to set FILEMAKER_XML_URL."
_writeerrorlog "checksum2filemaker" "The filemaker xml path was not set, so the script was unable to run."
exit 1
fi
while [ "${*}" != "" ] ; do
INPUT="${1}"
if [[ ! -f "${INPUT}/metadata/checksum.md5" ]] ; then
_report -dt "${INPUT} does not have a checksum.md5 file, skipping for $(basename "${INPUT}")"
-writeerrorlog "checksum2filemaker" "${INPUT} did not have a checksum.md5 file, so it was skipped."
shift
continue
fi
OLDIFS="${IFS}"
IFS=$'\n'
echo "Uploading checksum data for $(basename "${INPUT}"). Please wait…"
for HASH in $(cat "${INPUT}/metadata/checksum.md5"); do
if [[ "$HASH" ]] ; then
HASHINSERT=$(echo "$HASH" | awk '{ printf " --data-urlencode \"hashdigest=" $1 "\" --data-urlencode \"FILENAME=" $NF "\" --data-urlencode \"hashdigest_type=MD5\"" }')" --data-urlencode \"source=${INPUT}\" --data-urlencode \"uniq="checksum.md5.${INPUT}.${HASH}.${1}"\""
HASHCMD="curl -s -S -G ${HASHINSERT} \"http://${FILEMAKER_XML_URL}?-db=${FILEMAKER_DB}&-lay=checksums&-new\" 1>/dev/null"
eval "${HASHCMD}"
fi
done
IFS="${OLDIFS}"
echo "Done uploading metadata for $(basename "${1}")."
shift
done