forked from mediamicroservices/mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paperingest
executable file
·59 lines (46 loc) · 2.37 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
58
59
#!/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"
submissionMetadataDir="$OUTDIR_PAPER/$mediaid/metadata/submissionDocumentation"
logdir="$OUTDIR_PAPER/$mediaid/logs"
mkdir -p "$origdir"
mkdir -p "$submissionMetadataDir"
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 &> "$submissionMetadataDir/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}" >> "$submissionMetadataDir/operation_process.txt"
echo "datetime_end: ${end}" >> "$submissionMetadataDir/operation_process.txt"
echo "serial number: ${serial_number}" >> "$submissionMetadataDir/operation_process.txt"
echo "model id: ${model}" >> "$submissionMetadataDir/operation_process.txt"
echo "os: ${os}" >> "$submissionMetadataDir/operation_process.txt"
echo "identifier: ${mediaid}" >> "$submissionMetadataDir/operation_process.txt"
echo "operator: ${op}" >> "$submissionMetadataDir/operation_process.txt"
echo "command: ${command}" >> "$submissionMetadataDir/operation_process.txt"
echo done scanning "$mediaid"
_log -e