- Python 61.7%
- JavaScript 20.5%
- Vue 14%
- Shell 3.1%
- CSS 0.5%
- Other 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Fixes the mkdir race in test_api_write.py, corrects the README on re-printing, and makes /opt/cups-dash root-owned in install.sh. Reviewed by the coordinator only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
| backend | ||
| deploy | ||
| frontend | ||
| .gitignore | ||
| README.md | ||
cups-dash
A dashboard at http://cups.local:8080 for the Brother HL-L2310D on the CUPS LXC. It shows printer state, job and page counts, estimated toner and drum life, the queue and the CUPS error log, and lets you upload a PDF, control the queue, and view or re-print past jobs. There is no login: anyone on the LAN can use it.
Build and deploy
From the Mac, in the repo root:
deploy/push.sh
This runs npm ci && npm run build in frontend/, copies backend/pyproject.toml, backend/cups_dash, frontend/dist and deploy/ to /opt/cups-dash on the box over ssh, then runs install.sh there as root. It connects to root@cups.local unless you set CUPS_DASH_HOST. install.sh is safe to re-run. It installs the system packages, creates the cups-dash user (no login shell, groups lp, lpadmin, adm), writes /etc/cups-dash/config.toml only if missing, builds the venv with pip install backend[host], makes the CUPS change below, and enables and restarts cups-dash.service. The box needs Python 3.11 or newer.
To check a deploy, run ssh root@cups.local /opt/cups-dash/deploy/smoke.sh. Smoke needs at least one completed job with pages > 0 among recent jobs, so it fails on a box that has never printed. It ignores config.toml. If you changed the queue or paths, set the QUEUE, SPOOL_DIR and ERROR_LOG env vars.
Configuration
/etc/cups-dash/config.toml (template: deploy/config.toml.example; override the path with CUPS_DASH_CONFIG). Every key is optional, and a missing file gives these defaults. Restart with systemctl restart cups-dash after editing.
| Key | Default |
|---|---|
queue |
"Brother_HL-L2310D" |
data_dir |
"/var/lib/cups-dash" |
spool_dir |
"/var/spool/cups" |
error_log |
"/var/log/cups/error_log" |
static_dir |
"/opt/cups-dash/frontend/dist" |
host |
"0.0.0.0" |
port |
8080 |
allowed_hosts |
["cups.local", "192.168.22.79", "localhost", "127.0.0.1"] |
max_upload_mb |
50 |
poll_seconds |
5 |
drum_yield |
12000 |
[toner_yields] |
"TN-2410" = 1200, "TN-2420" = 3000 |
host and port are not read by the app. The listen address comes from ExecStart in deploy/cups-dash.service (0.0.0.0:8080). max_upload_mb is enforced by the server. The browser form has its own fixed 50 MB limit. [toner_yields] replaces the defaults rather than merging. The dashboard's model list stays fixed at TN-2410 and TN-2420. allowed_hosts is the list of Host names the server accepts, so add any other name or IP you use to reach it.
Viewing and archive
Only files starting %PDF or %! get an in-browser view. Other formats can only be downloaded or re-printed. Only a job's first document is archived.
CUPS change
install.sh sets PreserveJobFiles 86400 in /etc/cups/cupsd.conf (it replaces an existing PreserveJobFiles line, otherwise it appends one) and restarts CUPS. This keeps each job's files for 24 hours so the archiver can copy them before CUPS deletes them. Before the first edit it saves a copy at /etc/cups/cupsd.conf.pre-cups-dash. If the line is already 86400, nothing is changed.
Cartridge counts
Toner and drum are estimates (shown as "est."), not readings from the printer. In the Consumables card, press Set cartridge (or Replace once one is set) for Toner or Drum, pick the model (toner TN-2410 or TN-2420, drum DR-2400), enter the pages already used on it (0 for a new one), and press Save. Do this each time you fit a new cartridge. Page yields come from toner_yields and drum_yield in the config.
Tests
Backend, from backend/:
python3 -m venv .venv
.venv/bin/pip install -e '.[dev]'
.venv/bin/pytest
Use .[dev], not the host extra, which needs the CUPS development headers. Frontend, from frontend/:
npm ci
npm test