-
Notifications
You must be signed in to change notification settings - Fork 27
/
paperingest
executable file
·57 lines (44 loc) · 2.13 KB
/
paperingest
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
#!/bin/bash
REQUIRECONFIG="Y"
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;};
_cleanup(){
_log -a "Process aborted"
exit 1
}
trap _cleanup SIGHUP SIGINT SIGTERM
_log -b
_ask_operator
_ask_mediaid
if [ -d "${OUTDIR_PAPER}/${MEDIAID}" ] ; then
_report -wdt "It looks like this ${MEDIAID} was already scanned. If you want to overwrite the existing one please delete ${MEDIAID} first and then try again."
exit
fi
_free_space 5 "${OUTDIR_PAPER}"
ORIGDIR="${OUTDIR_PAPER}/${MEDIAID}/objects"
LOGDIR="${OUTDIR_PAPER}/${MEDIAID}/metadata/logs"
mkdir -p "${ORIGDIR}"
mkdir -p "${LOGDIR}"
START=$(date -u "+%Y%m%dT%H%M%SZ")
COMMAND="fscanx --adf --rgb --bits 8 --resolution 600 --paper-width 10200 --paper-height 13200 --rotate-n-n --left 0 --width 10200 --top 0 --height 13200 --double-feed n --tiff --no-jpeg --images-per-file 1 --compress zlib '${ORIGDIR}/${MEDIAID}_.tif'"
exec &> "${LOGDIR}/fscanx_process.txt"
eval "${COMMAND}"
FIRST=$(find "${ORIGDIR}" -type f -mindepth 1 -maxdepth 1 ! -name ".*" -exec ls -1rt '{}' \; | head -n 1)
LAST=$(ls -1t "${ORIGDIR}" | head -n 1)
open -a /Applications/Preview.app/ "${FIRST}" "${ORIGDIR}/${LAST}"
END=$(date -u "+%Y%m%dT%H%M%SZ")
SYSTEM_DATA=$(system_profiler SPHardwareDataType)
#These retrieved the right info on the Mac I'm using, but I don't know how standard the output is
SERIAL_NUMBER=$(echo "${SYSTEM_DATA}" | grep "Serial Number" | awk '{ print $4 }')
MODEL=$(echo "${SYSTEM_DATA}" | grep "Model Identifier" | awk '{ print $3; }')
OS=$(system_profiler SPSoftwareDataType | grep "System Version" | awk '{ print substr(${0}, index(${0},$3)); }')
echo "datetime_start: ${START}" >> "${LOGDIR}/capture.log"
echo "datetime_end: ${END}" >> "${LOGDIR}/capture.log"
echo "serial number: ${SERIAL_NUMBER}" >> "${LOGDIR}/capture.log"
echo "model id: ${MODEL}" >> "${LOGDIR}/capture.log"
echo "os: ${OS}" >> "${LOGDIR}/capture.log"
echo "identifier: ${MEDIAID}" >> "${LOGDIR}/capture.log"
echo "operator: ${OP}" >> "${LOGDIR}/capture.log"
echo "command: ${COMMAND}" >> "${LOGDIR}/capture.log"
echo done scanning "${MEDIAID}"
_log -e