9cd45cc3459f40d05fdb96eabb34f2383125806a
scan-station
Scan-to-Paperless for a Fujitsu ScanSnap iX500 attached to a Linux VM (Proxmox USB passthrough). Load paper (or press the scan button) and the pages are scanned duplex, compressed, stripped of blank pages, and uploaded to Paperless-ngx.
How it works
iX500 (USB) -> scanbd (polls button + page-loaded sensor)
-> scan.sh: scanimage -> JPEG -> blank filter -> img2pdf -> Paperless API
- Triggers: scan button (
scanaction) and paper loaded in the feeder (pageloadedaction, 3 s settle delay). - Blank pages: pages below
BLANK_THRESHOLDink are left out of the upload. A full copy of every scan (blanks included) is kept in/var/lib/scan-station/archive. - Barcode splitting: patch sheets work with Paperless barcode separators. The blank back of a patch sheet is dropped by the blank filter, the barcode front is consumed by Paperless.
- Failures: if an upload fails, the PDF is saved to
/var/lib/scan-station/failed. - Cleanup: a daily cron job deletes archive files older than 60 days.
Layout
| Path | Installed to |
|---|---|
scripts/scan.sh |
/etc/scanbd/scripts/scan.sh |
config/env.example |
/etc/scan-station/env (copy, then edit) |
config/scanbd-actions.conf |
merge into /etc/scanbd/scanbd.conf |
config/scan-station-cleanup.cron |
/etc/cron.d/scan-station-cleanup |
install.sh |
helper that does the above (except the scanbd.conf merge) |
Setup
- Proxmox: pass the scanner through to the VM (
qm set <vmid> -usb0 host=<vendor:product>; get IDs fromlsusb). - Packages (VM):
sudo apt install sane-utils scanbd img2pdf imagemagick curl - SANE config. On this Ubuntu install scanbd uses
/etc/scanbdas its SANE config dir (SANE_CONFIG_DIRinscanbd.conf).echo net | sudo tee /etc/sane.d/dll.conf echo localhost | sudo tee /etc/sane.d/net.conf echo fujitsu | sudo tee /etc/scanbd/dll.conf - Permissions:
sanedmust be in thescannergroup (sudo usermod -aG scanner saned). - Install the files:
sudo ./install.sh sudo nano /etc/scan-station/env # set PAPERLESS_TOKEN - scanbd actions: replace the
action scan { ... }block in/etc/scanbd/scanbd.confwith the blocks inconfig/scanbd-actions.conf. Comment out the other default actions (copy, email, file). - Start:
sudo systemctl enable --now scanbd sudo systemctl restart scanbd
Config (/etc/scan-station/env)
| Variable | Meaning |
|---|---|
PAPERLESS_URL |
Base URL of Paperless-ngx |
PAPERLESS_TOKEN |
API token (dedicated user recommended) |
RESOLUTION |
Scan DPI (200 is plenty for OCR) |
ROTATE |
0 or 180 if scans come out upside down |
BLANK_THRESHOLD |
Ink fraction below which a page counts as blank (default 0.003) |
Operations
journalctl -t scan-station -n 30 --no-pager # script log (shows skipped blanks + ink values)
journalctl -u scanbd -n 50 --no-pager # scanbd log
scanimage -L # lists device via scanbd
Notes and gotchas
- scanbd owns the USB device. Run
sudo systemctl stop scanbdbefore usingscanimage -d fujitsudirectly. - Large uploads through a reverse proxy need a raised body limit. For Nginx Proxy Manager, add in the proxy host's Advanced tab:
Cloudflare's free plan caps uploads at 100 MB (413); JPEG compression keeps files well under that.
client_max_body_size 500m; proxy_request_buffering off; proxy_read_timeout 300s; proxy_send_timeout 300s; client_body_timeout 300s; - The paper-loaded trigger needs a 0 to 1 transition. Remove and reload paper if scanbd started with paper already in the feeder.
- Duplex backs flipped but fronts fine? Rotate even-numbered pages with
mogrify -rotate 180 "$WORK"/p_*[02468].*before the PDF step. - Never commit the real
envfile (it is in.gitignore).
Languages
Shell
100%