Skip to content

Commit 0135bcd

Browse files
authored
Merge branch 'main' into dependabot/github_actions/dot-github/workflows/actions/create-github-app-token-2
2 parents 1b2ad44 + 343a29a commit 0135bcd

File tree

14 files changed

+214
-4
lines changed

14 files changed

+214
-4
lines changed

.github/workflows/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
Dependabot:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v5
1313
- name: Install perquisite
1414
run: |
1515
pip3 install dockerfile-parse

.github/workflows/docker-image.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
push_matrix: ${{ steps.set-matrix.outputs.push_matrix }}
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
2020
with:
2121
fetch-depth: 0
2222
- name: Setup Matrix-Jobs
@@ -64,7 +64,7 @@ jobs:
6464
${{ insert }}: ${{ fromJson(needs.Setup.outputs.build_matrix) }}
6565
steps:
6666
- name: Checkout
67-
uses: actions/checkout@v4
67+
uses: actions/checkout@v5
6868

6969
- name: Login to Docker Hub
7070
if: github.event_name == 'push'
@@ -157,7 +157,7 @@ jobs:
157157
${{ insert }}: ${{ fromJson(needs.Setup.outputs.push_matrix) }}
158158
steps:
159159
- name: Checkout
160-
uses: actions/checkout@v4
160+
uses: actions/checkout@v5
161161

162162
- name: Login to Docker Hub
163163
uses: docker/login-action@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

scanbd2smb/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog:
2+
## Version 0.1.0
3+
- First release of scandb2smb addon

scanbd2smb/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM debian:bookworm-20250908-slim
2+
3+
RUN apt-get update && \
4+
apt-get install -y \
5+
sane \
6+
scanbd \
7+
imagemagick \
8+
exactimage \
9+
pdftk \
10+
tesseract-ocr \
11+
tesseract-ocr-eng \
12+
libusb-dev \
13+
smbclient \
14+
jq \
15+
dbus \
16+
&& rm -rf /tmp/* /var/{cache,log}/* /var/lib/apt/lists/*
17+
18+
COPY ./scan.sh /scan.sh
19+
RUN chmod +x /scan.sh
20+
21+
RUN sed -i '/action scan {/,/}/s|script = ".*"|script = "/scan.sh"|' /etc/scanbd/scanbd.conf
22+
23+
COPY ./entrypoint.sh /entrypoint.sh
24+
RUN chmod +x /entrypoint.sh
25+
26+
ENTRYPOINT [ "/entrypoint.sh" ]
27+
28+
ARG VERSION
29+
LABEL \
30+
io.hass.name="scanbd2smb" \
31+
io.hass.description="Scan from your USB Scanner to a SMB Folder." \
32+
io.hass.version="${VERSION}" \
33+
io.hass.type="addon" \
34+
io.hass.arch="armhf|aarch64|i386|amd64|armv7" \
35+
maintainer="Nils Stein <[email protected]>" \
36+
org.opencontainers.image.title="scanbd2smb" \
37+
org.opencontainers.image.description="Scan from your USB Scanner to a SMB Folder." \
38+
org.opencontainers.image.vendor="Nils Home Assistant Add-ons" \
39+
org.opencontainers.image.authors="Nils Stein <[email protected]>" \
40+
org.opencontainers.image.licenses="MIT" \
41+
org.opencontainers.image.source="https://github.com/mietzen/hassio-addons" \
42+
org.opencontainers.image.documentation="https://github.com/mietzen/hassio-addons/blob/main/p910nd/README.md"

scanbd2smb/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## **Status: Untested Beta ×**
2+
3+
# Home Assistant Add-on: scanbd2smb
4+
5+
Enables you to scan from your USB scanner directly to a SMB share.
6+
7+
## About
8+
9+
This add-on uses **scanbd** to listen for scanner button presses and automatically scans documents.
10+
Scans are processed with **OCR (Tesseract)** and stored as compressed searchable PDFs on your SMB share.
11+
12+
## Installation
13+
14+
1. Navigate in your Home Assistant frontend to **Settings** -> **Add-ons** -> **Add-on Store** and add this URL as an additional repository: `https://github.com/mietzen/hassio-addons`
15+
2. Refresh your browser.
16+
3. Find the "scanbd2smb" add-on and click the "INSTALL" button.
17+
4. Configure the add-on and click on "START".

scanbd2smb/config.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: scanbd2smb
2+
version: 0.1.0
3+
slug: scanbd2smb
4+
description: Enables you to scan from your USB Scanner to a SMB Folder.
5+
url: https://github.com/mietzen/hassio-addons/tree/master/scanbd
6+
arch:
7+
- armhf
8+
- armv7
9+
- aarch64
10+
- amd64
11+
- i386
12+
startup: application
13+
boot: auto
14+
homeassistant_api: false
15+
hassio_api: false
16+
hassio_role: manager
17+
stdin: true
18+
image: mietzen/hass-addon-scanbd2smb
19+
init: false
20+
usb: true
21+
22+
options:
23+
smb_share: ""
24+
smb_user: ""
25+
smb_password: ""
26+
ocr_language: "eng"
27+
scan_resolution: 300
28+
scan_mode: "Color"
29+
30+
schema:
31+
smb_share: str
32+
smb_user: str
33+
smb_password: str
34+
ocr_language: str
35+
scan_resolution: int
36+
scan_mode: str
37+
log_level: list(debug|info|warning|error)?

scanbd2smb/entrypoint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Read options.json into env vars
5+
export SMB_SHARE=$(jq -r '.smb_share' /data/options.json)
6+
export SMB_USER=$(jq -r '.smb_user' /data/options.json)
7+
export SMB_PASSWORD=$(jq -r '.smb_password' /data/options.json)
8+
export OCR_LANGUAGE=$(jq -r '.ocr_language' /data/options.json)
9+
export SCAN_RESOLUTION=$(jq -r '.scan_resolution' /data/options.json)
10+
export SCAN_MODE=$(jq -r '.scan_mode' /data/options.json)
11+
12+
if ! dpkg -l | grep -q "tesseract-ocr-${OCR_LANGUAGE}"; then
13+
echo "OCR Language: $OCR_LANGUAGE not installed! Installing:"
14+
apt-get update
15+
apt-get install --yes "tesseract-ocr-${OCR_LANGUAGE}"
16+
fi
17+
18+
echo "ScanBD starting with:"
19+
echo " SMB_SHARE=$SMB_SHARE"
20+
echo " SMB_USER=$SMB_USER"
21+
echo " OCR_LANGUAGE=$OCR_LANGUAGE"
22+
echo " SCAN_RESOLUTION=$SCAN_RESOLUTION"
23+
echo " SCAN_MODE=$SCAN_MODE"
24+
25+
mkdir -p /run/dbus
26+
dbus-daemon --system --fork
27+
28+
exec /usr/sbin/scanbd -f

scanbd2smb/icon.png

25.7 KB
Loading

scanbd2smb/scan.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
TMP_DIR=$(mktemp -d)
5+
FILE_NAME="scan_$(date +%Y-%m-%d-%H%M%S)"
6+
7+
echo 'Scanning...'
8+
scanimage --resolution "$SCAN_RESOLUTION" \
9+
--batch="$TMP_DIR/scan_%03d.pnm" \
10+
--format=pnm \
11+
--mode "$SCAN_MODE" \
12+
--source "ADF Front"
13+
14+
echo "Output saved in $TMP_DIR/scan*.pnm"
15+
cd "$TMP_DIR"
16+
17+
# Convert to TIFF
18+
for i in scan_*.pnm; do
19+
echo "Converting $i"
20+
convert "$i" "$i.tif"
21+
done
22+
23+
# OCR
24+
echo 'Performing OCR...'
25+
for i in scan_*.tif; do
26+
echo "Processing $i"
27+
tesseract "$i" "$i" -l "$OCR_LANGUAGE" hocr
28+
hocr2pdf -i "$i" -s -o "$i.pdf" < "$i.hocr"
29+
done
30+
31+
# Merge PDFs
32+
echo 'Merging PDFs...'
33+
pdftk *.tif.pdf cat output compiled.pdf
34+
35+
# Compress final PDF
36+
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \
37+
-dNOPAUSE -dQUIET -dBATCH \
38+
-sOutputFile="$FILE_NAME.pdf" compiled.pdf
39+
40+
# Upload via Samba
41+
smbclient "$SMB_SHARE" -U "$SMB_USER"%"$SMB_PASSWORD" -c "put $FILE_NAME.pdf"
42+
43+
# Cleanup
44+
rm -rf "$TMP_DIR"

0 commit comments

Comments
 (0)