Skip to content

Commit

Permalink
Standardized variables and functions across all mm scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
dinahhandel committed Oct 26, 2015
1 parent 9524798 commit ad37593
Show file tree
Hide file tree
Showing 31 changed files with 1,906 additions and 1,904 deletions.
80 changes: 40 additions & 40 deletions barcodeinterpret
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
#!/bin/bash
# interpret Interleaved 2/5 barcode 58 byte barcode values used by the ProBell tape management system

scriptdir=$(dirname "${0}")
. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;};
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;};

cleanup(){
_cleanup(){
_log -a "Process aborted"
exit 1
}

trap cleanup SIGHUP SIGINT SIGTERM
trap _cleanup SIGHUP SIGINT SIGTERM
_log -b

if test $# != 1 ; then
if test "${#}" != 1 ; then
echo "You must supply one argument, a scanned interleaved 2/5 barcode value"; exit
fi

barcode="${1}"
BARCODE="${1}"

translatebyte()
{
val=$(echo $1 | echo $(cut -c $2-$3) + 32 | bc)
if [ "$val" = 131 ] ; then
echo 9 | awk '{printf("%c", $0);}'
VAL=$(echo $1 | echo $(cut -c $2-$3) + 32 | bc)
if [ "${VAL}" = 131 ] ; then
echo 9 | awk '{printf("%c", ${0});}'
else
echo $val | awk '{printf("%c", $0);}'
echo "${VAL}" | awk '{printf("%c", ${0});}'
fi
}
addcolons()
_addcolons()
{
echo $(echo $1 | cut -c 1-2):$(echo $1 | cut -c 3-4):$(echo $1 | cut -c 5-6):$(echo $1 | cut -c 7-8)
echo $(echo "${1}" | cut -c 1-2):$(echo "${1}" | cut -c 3-4):$(echo "${1}" | cut -c 5-6):$(echo "${1}" | cut -c 7-8)
}

get_ids()
_get_ids()
{
barcode=$1
c00=$(translatebyte $barcode 2 3)
c01=$(translatebyte $barcode 4 5)
c02=$(translatebyte $barcode 6 7)
c03=$(translatebyte $barcode 8 9)
c04=$(translatebyte $barcode 10 11)
c05=$(translatebyte $barcode 12 13)
c06=$(translatebyte $barcode 14 15)
c07=$(translatebyte $barcode 16 17)
c08=$(translatebyte $barcode 18 19)
c09=$(translatebyte $barcode 20 21)
c10=$(translatebyte $barcode 22 23)
c11=$(translatebyte $barcode 24 25)
c12=$(translatebyte $barcode 26 27)
c13=$(translatebyte $barcode 28 29)
c14=$(translatebyte $barcode 30 31)
c15=$(translatebyte $barcode 32 33)
c16=$(translatebyte $barcode 34 35)
c17=$(translatebyte $barcode 36 37)
c18=$(translatebyte $barcode 38 39)
c19=$(translatebyte $barcode 40 41)
echo $c00$c01$c02$c03$c04$c05$c06$c07$c08$c09$c10$c11$c12$c13$c14$c15$c16$c17$c18$c19
BARCODE=$1
c00=$(translatebyte "${BARCODE}" 2 3)
c01=$(translatebyte "${BARCODE}" 4 5)
c02=$(translatebyte "${BARCODE}" 6 7)
c03=$(translatebyte "${BARCODE}" 8 9)
c04=$(translatebyte "${BARCODE}" 10 11)
c05=$(translatebyte "${BARCODE}" 12 13)
c06=$(translatebyte "${BARCODE}" 14 15)
c07=$(translatebyte "${BARCODE}" 16 17)
c08=$(translatebyte "${BARCODE}" 18 19)
c09=$(translatebyte "${BARCODE}" 20 21)
c10=$(translatebyte "${BARCODE}" 22 23)
c11=$(translatebyte "${BARCODE}" 24 25)
c12=$(translatebyte "${BARCODE}" 26 27)
c13=$(translatebyte "${BARCODE}" 28 29)
c14=$(translatebyte "${BARCODE}" 30 31)
c15=$(translatebyte "${BARCODE}" 32 33)
c16=$(translatebyte "${BARCODE}" 34 35)
c17=$(translatebyte "${BARCODE}" 36 37)
c18=$(translatebyte "${BARCODE}" 38 39)
c19=$(translatebyte "${BARCODE}" 40 41)
echo "${c00$c01$c02$c03$c04$c05$c06$c07$c08$c09$c10$c11$c12$c13$c14$c15$c16$c17$c18$c19}"
}

ids=$(get_ids $barcode)
IDS=$(_get_ids "${BARCODE}")

materialid=$(echo $ids | cut -d ' ' -f 2)
if [[ $(echo "$materialid" | tail -c +9 | head -c 1) == "H" ]] ; then
materialid="${materialid}D"
MATERIALID=$(echo "${IDS}" | cut -d ' ' -f 2)
if [[ $(echo "${MATERIALID}" | tail -c +9 | head -c 1) == "H" ]] ; then
MATERIALID="${MATERIALID}D"
fi
echo deviceid,$(echo $ids | cut -d ' ' -f 1),materialid,$materialid,som,$(addcolons $(echo $barcode | cut -c 42-49)),duration,$(addcolons $(echo $barcode | cut -c 50-57))
echo DEVICEID,$(echo "${IDS}" | cut -d ' ' -f 1),MATERIALID,${MATERIALID},SOM,$(_addcolons $(echo "${BARCODE}" | cut -c 42-49)),duration,$(_addcolons $(echo "${BARCODE}" | cut -c 50-57))
_log -e
32 changes: 16 additions & 16 deletions blackatends
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
#!/bin/bash
# blackatends
# Accepts one or many video files as an input and determines how many frames of black are at the beginning and at the end
scriptdir=$(dirname "${0}")
. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;};
version=1.0
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;};
VERSION=1.0

cleanup(){
_cleanup(){
_log -a "Process aborted"
exit 1
}

trap cleanup SIGHUP SIGINT SIGTERM
trap _cleanup SIGHUP SIGINT SIGTERM

usage(){
_usage(){
echo
echo "$(basename "${0}") ${version}"
echo "$(basename "${0}") ${VERSION}"
echo "This program will report on the number of black frames at the beginning and end of a video file."
echo
echo "Usage: $(basename $0) file1 [ file2 ... ]"
echo "Usage: $(basename ${0}) file1 [ file2 ... ]"
echo
echo "Options:"
echo " -h display this help"
echo
exit
}
[ "$#" = 0 ] && usage
[ "${#}" = 0 ] && _usage

# command-line options to set mediaid and original variables
OPTIND=1
while getopts ":h" opt; do
case "$opt" in
h) usage ;;
\?) echo "Invalid option: -$OPTARG" ; exit 1 ;;
:) echo "Option -$OPTARG requires an argument" ; exit 1 ;;
while getopts ":h" OPT; do
case "${OPT}" in
h) _usage ;;
\?) echo "Invalid option: -${OPTARG}" ; exit 1 ;;
:) echo "Option -${OPTARG} requires an argument" ; exit 1 ;;
esac
done
shift $(( ${OPTIND} - 1 ))

while [ "${*}" != "" ] ; do
_log -b
[ "$#" != 0 ] && sourcefile="${1}"
black_at_ends "$sourcefile"
[ "${#}" != 0 ] && SOURCEFILE="${1}"
_black_at_ends "${SOURCEFILE}"
_log -e
shift
done
24 changes: 12 additions & 12 deletions checksum2filemaker
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/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
VERSION=1.0

SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;};
Expand All @@ -10,23 +10,23 @@ SCRIPTDIR=$(dirname "${0}")
[ -z "${FILEMAKER_XML_URL}" ] && { echo "The filemaker xml path must be set. Run mmconfig to set FILEMAKER_XML_URL." ; exit 1 ;};

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")"
INPUT="${1}"
if [[ ! -f "${INPUT}/metadata/checksum.md5" ]] ; then
_report -dt "${INPUT} does not have a checksum.md5 file, skipping for $(basename "${INPUT}")"
shift
continue
fi
OLDIFS=$IFS
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"
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
IFS="${OLDIFS}"
echo "Done uploading metadata for $(basename "${1}")."
shift
done
Loading

0 comments on commit ad37593

Please sign in to comment.