forked from budney/docker-scanbd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscan.script
More file actions
executable file
·32 lines (27 loc) · 890 Bytes
/
scan.script
File metadata and controls
executable file
·32 lines (27 loc) · 890 Bytes
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
#!/bin/bash
# Thanks to Andreas Gohr (http://www.splitbrain.org/) for the initial work
# https://github.com/splitbrain/paper-backup/
export LANGUAGE="eng"
export HOME=/service/scan-button
export TMPDIR=$HOME/work
FILE_NAME=scan_$(date +%Y%m%d-%H%M%S)
OUT_DIR=/service/scan-processor/work/
# Extra insurance against folder collisions
TEMPLATE="tmp.$(tr -dc '0-9A-Za-z' < /dev/urandom | head -c 12).XXXXXX"
WORK=$(/bin/mktemp -d -t "${TEMPLATE}")
cd $WORK
echo 'Scanning...'
scanimage \
-d "$SCANBD_DEVICE" \
--batch="$WORK/$FILE_NAME-%03d.pnm" \
--resolution 300 \
--source 'ADF Duplex' \
--format pnm \
--mode Color \
&& echo 'Scan complete.'
cd $TMPDIR
# Submit the scan for processing, unless there are no image files
if ls "$WORK" | egrep -q pnm; then
mv $WORK $OUT_DIR \
&& echo "Scan saved in $OUT_DIR$(basename $WORK)/$FILE_NAME-*.pnm"
fi