{"id":35274830,"url":"https://github.com/hensing/scan-to-paperless","last_synced_at":"2026-05-17T12:36:29.362Z","repository":{"id":328515610,"uuid":"1115835993","full_name":"hensing/scan-to-paperless","owner":"hensing","description":"A secure SMB bridge for hardware scanners to automatically upload documents to Paperless-ngx. Features multi-arch support (x86/ARM), non-root execution, and auto-archiving.","archived":false,"fork":false,"pushed_at":"2026-03-25T15:40:51.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-26T02:10:17.356Z","etag":null,"topics":["alpine-linux","automation","digitization","dms","docker","inotify","paperless-ngx","raspberry-pi","samba","scan-to-paperless","scanner","scansnap","self-hosted","smb-shares"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hensing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-13T16:47:13.000Z","updated_at":"2026-03-25T15:45:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hensing/scan-to-paperless","commit_stats":null,"previous_names":["hensing/scan-to-paperless"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hensing/scan-to-paperless","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensing%2Fscan-to-paperless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensing%2Fscan-to-paperless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensing%2Fscan-to-paperless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensing%2Fscan-to-paperless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hensing","download_url":"https://codeload.github.com/hensing/scan-to-paperless/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hensing%2Fscan-to-paperless/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33138696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpine-linux","automation","digitization","dms","docker","inotify","paperless-ngx","raspberry-pi","samba","scan-to-paperless","scanner","scansnap","self-hosted","smb-shares"],"created_at":"2025-12-30T13:39:41.674Z","updated_at":"2026-05-17T12:36:29.357Z","avatar_url":"https://github.com/hensing.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📠 Scan to Paperless Bridge\n\n[![Docker Build \u0026 Publish](https://github.com/hensing/scan-to-paperless/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/hensing/scan-to-paperless/actions/workflows/docker-publish.yml)\n![Platform](https://img.shields.io/badge/platform-linux%2Famd64%20%7C%20linux%2Farm64-blue)\n![License](https://img.shields.io/badge/license-MIT-green)\n\n**Author:** Dr. Henning Dickten ([@hensing](https://github.com/hensing))\n\nA lightweight, secure, and Dockerized bridge designed for **Raspberry Pi** and generic Linux servers. It provides a Samba (SMB) share for hardware document scanners.\n\nOnce a scan is saved to the share, this container detects the completed file, uploads it directly to **Paperless-ngx** via API, and optionally archives or cleans up the local file.\n\nSupports both **single-user** (simple env var config) and **multi-user** mode (one share and API key per person).\n\n---\n\n### 🔄 How it works\n\n**Single-user mode**\n\n```mermaid\ngraph LR\n    A[🖨️ Hardware Scanner] -- SMB Port 445 --\u003e B(📂 /data/inbox)\n    B --\u003e C[🐳 Container Watcher]\n    C -- API Token --\u003e D[📄 Paperless-NGX]\n    C -- Move/Delete --\u003e E(📦 /data/archive)\n```\n\n**Multi-user mode**\n\n```mermaid\ngraph TD\n    SCAN[🖨️ Hardware Scanner]\n\n    subgraph alice [Alice]\n        direction TB\n        AI(📂 alice_scans)\n        AW[🐳 Watcher]\n        AA(📦 archive)\n        AI --\u003e AW --\u003e AA\n    end\n\n    subgraph bob [Bob]\n        direction TB\n        BI(📂 bob_docs)\n        BW[🐳 Watcher]\n        BA(📦 archive)\n        BI --\u003e BW --\u003e BA\n    end\n\n    PL[📄 Paperless-NGX]\n\n    SCAN -- SMB: alice_scans --\u003e AI\n    SCAN -- SMB: bob_docs --\u003e BI\n    AW -- Alice's API Key --\u003e PL\n    BW -- Bob's API Key --\u003e PL\n```\n\n## ✨ Features\n\n- **🚀 Multi-Arch Support:** Optimized for `linux/amd64` and `linux/arm64` (Raspberry Pi).\n- **👥 Multi-User Support:** Each user gets their own Samba share, SMB credentials, and Paperless-NGX API key.\n- **🔒 Secure by Default:** Binds to privileged SMB port 445 but drops privileges to run as a non-root user (configurable `PUID`/`PGID`).\n- **📂 Samba Integration:** Built-in SMB server compliant with modern scanners.\n- **⚡ Smart Detection:** Uses `inotify` to detect `close_write` events (prevents processing incomplete files).\n- **🏷️ Auto-Tagging:** Automatically apply tags to uploaded documents — configurable per user in multi-user mode.\n- **🧹 Auto-Cleanup:** Options to archive or delete files after successful upload.\n- **🛡️ SSL Support:** Full support for HTTPS and self-signed certificates.\n\n## 🔗 Recommended Workflow\n\nThis tool works best as part of a modern document management ecosystem. We highly recommend checking out:\n\n* **[Paperless-ngx Documentation](https://docs.paperless-ngx.com/)**: The official documentation for the backend system.\n* **[Paperless-GPT](https://github.com/icereed/paperless-gpt)**: An amazing tool to add AI-powered analysis, tagging, and renaming to your documents after they have been uploaded.\n\n## 🚀 Quick Start\n\n### Single-User Mode\n\n#### 1. Configuration\n\nCreate your `.env` file based on the example:\n\n```bash\ncp .env.example .env\n```\n\n**Minimal `.env` example:**\n\n```dotenv\nPAPERLESS_URL=https://paperless.local:8000\nPAPERLESS_API_KEY=your-super-secret-token\nSMB_USER=scanner\nSMB_PASSWORD=scan123\nPUID=1000\nPGID=1000\n```\n\n#### 2. Docker Compose\n\nCreate a `docker-compose.yml` (or use the one provided):\n\n```yaml\nservices:\n  scan-to-paperless:\n    image: ghcr.io/hensing/scan-to-paperless:latest\n    container_name: scan-to-paperless\n    restart: unless-stopped\n    ports:\n      - \"445:445\"\n    env_file:\n      - .env\n    volumes:\n      - ./data:/data\n      - ./config:/config:ro\n```\n\nStart the container:\n\n```bash\ndocker compose up -d\n```\n\n#### 3. Scanner Setup\n\nConfigure your physical scanner (Brother, Canon, HP, etc.) with these settings:\n\n* **Protocol:** SMB / CIFS\n* **Server:** IP of your Docker host\n* **Port:** 445\n* **Share Name:** `scanner` (default)\n* **Username:** `scanner` (default)\n* **Password:** `scan123` (default)\n\n---\n\n### 👥 Multi-User Mode\n\nMulti-user mode activates automatically when `./config/users.conf` exists. Each user gets an isolated Samba share and uploads to Paperless with their own API key.\n\n#### 1. Create the user config\n\n```bash\nmkdir -p config\ncp config/users.conf.example config/users.conf\n```\n\nEdit `config/users.conf` — one user per line, colon-separated:\n\n```\n# smb_user:smb_password:smb_share:paperless_api_key:paperless_tags(optional)\nalice:secretpassword1:alice_scans:paperless-api-token-alice:scanned,alice\nbob:secretpassword2:bob_docs:paperless-api-token-bob:scanned,bob\n```\n\n#### 2. Set global settings in `.env`\n\nOnly `PAPERLESS_URL` and optional processing settings are needed. The `SMB_*` and `PAPERLESS_API_KEY` variables are ignored in multi-user mode.\n\n```dotenv\nPAPERLESS_URL=https://paperless.local:8000\nPUID=1000\nPGID=1000\n```\n\n#### 3. Start the container\n\n```bash\ndocker compose up -d\n```\n\nEach user's files land in `/data/\u003csmb_user\u003e/inbox` and are archived to `/data/\u003csmb_user\u003e/archive`.\n\n\u003e **Upgrading from single-user:** No changes required. Single-user mode is auto-detected when `users.conf` is absent.\n\n---\n\n## ⚙️ Configuration Reference\n\n### Global Settings (`.env`)\n\n| Variable | Description | Default | Required |\n| :--- | :--- | :--- | :---: |\n| `PAPERLESS_URL` | Full URL to Paperless-NGX (e.g., `http://192.168.1.5:8000`) | - | ✅ |\n| `PAPERLESS_VERIFY_SSL` | Verify SSL certificates (`false` for self-signed) | `true` | ❌ |\n| `WHITELIST` | Allowed file extensions | `pdf,jpg,png,bmp` | ❌ |\n| `ARCHIVE` | `true` = Move to archive folder, `false` = Delete after upload | `true` | ❌ |\n| `UPLOAD_TIMEOUT` | Max time (seconds) for API upload | `30` | ❌ |\n| `SCAN_SETTLE_TIME` | Seconds to wait after detection before upload | `5` | ❌ |\n| `PUID` | User ID to run as (matches host user) | `1000` | ❌ |\n| `PGID` | Group ID to run as (matches host group) | `1000` | ❌ |\n\n### Single-User Settings (`.env`)\n\nIgnored when `config/users.conf` is present.\n\n| Variable | Description | Default |\n| :--- | :--- | :--- |\n| `PAPERLESS_API_KEY` | API Token from Paperless Settings → API Tokens | - |\n| `PAPERLESS_TAGS` | Comma-separated tags to apply | `\"\"` |\n| `SMB_USER` | Username for the scanner to login | `scanner` |\n| `SMB_PASSWORD` | Password for the scanner | `scan123` |\n| `SMB_SHARE` | Name of the SMB share | `scanner` |\n\n### Multi-User Settings (`config/users.conf`)\n\n| Field | Description | Required |\n| :--- | :--- | :---: |\n| `smb_user` | Linux/SMB username — unique, no spaces | ✅ |\n| `smb_password` | Password for the SMB share | ✅ |\n| `smb_share` | Share name visible to the scanner | ✅ |\n| `paperless_api_key` | API Token from Paperless Settings → API Tokens | ✅ |\n| `paperless_tags` | Comma-separated tags (optional, can be empty) | ❌ |\n\n\u003e **Note on Permissions:** This container starts as root to fix volume permissions and bind port 445, then immediately drops privileges to the user specified in `PUID`/`PGID`.\n\n---\n\n## 📂 Directory Structure\n\n**Single-user mode**\n\n```text\n/data\n├── inbox/      \u003c-- Scanner saves files here (monitored)\n└── archive/    \u003c-- Processed files are moved here (if ARCHIVE=true)\n```\n\n**Multi-user mode**\n\n```text\n/data\n├── alice/\n│   ├── inbox/    \u003c-- alice's Samba share (monitored)\n│   └── archive/  \u003c-- alice's processed files\n└── bob/\n    ├── inbox/    \u003c-- bob's Samba share (monitored)\n    └── archive/  \u003c-- bob's processed files\n```\n\n## 🛠️ Troubleshooting\n\n**🛑 \"Upload failed\" in logs**\n* Check if `PAPERLESS_URL` is reachable from inside the container.\n* Verify the API key (`PAPERLESS_API_KEY` or the key in `users.conf`).\n* If using a self-signed cert, try setting `PAPERLESS_VERIFY_SSL=false`.\n* Increase `SCAN_SETTLE_TIME`. Some network scanners report \"finished\" before the file is fully flushed to disk.\n\n**🚫 Scanner cannot connect (Network Error)**\n* Ensure port **445** is not blocked by a firewall on the host.\n* Windows/Mac hosts might use port 445 for their own sharing service. Ensure port 445 is free or use a different external port (note: many scanners hardcode 445).\n\n**📄 File is ignored**\n* Check the `WHITELIST` in `.env`.\n* The container waits for the `close_write` event. Ensure the scanner finishes writing the file completely.\n\n**👥 Multi-user: user cannot connect**\n* Verify the share name in `users.conf` matches what the scanner is configured with.\n* Check the container logs for `[INIT] Configured N user(s).` — if N is 0, the config file has a parsing issue.\n* Ensure all four required fields (`smb_user:smb_password:smb_share:paperless_api_key`) are present.\n\n---\n\n## 🤝 How to Contribute\n\nContributions, improvements, and bug fixes are welcome!\n\n1. Fork the project.\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`).\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).\n4. Push to the branch (`git push origin feature/AmazingFeature`).\n5. Open a Pull Request.\n\n**Note to Forks:** Please ensure that the original author credit remains intact in the license and documentation when forking or redistributing this project.\n\n## 👨‍💻 Development\n\nBuild the image locally:\n\n```bash\ndocker build -t scan-to-paperless .\n```\n\n## 📜 License\n\nDistributed under the MIT License. See [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhensing%2Fscan-to-paperless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhensing%2Fscan-to-paperless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhensing%2Fscan-to-paperless/lists"}