Files
Fichero/fichero_printer/run.sh
Tobias Leuschner 7ab3f8f4d2
Some checks failed
Deploy to GitHub Pages / build (push) Has been cancelled
Deploy to GitHub Pages / deploy (push) Has been cancelled
fix: remove container bluez, use host BlueZ via D-Bus, set DBUS_SYSTEM_BUS_ADDRESS
2026-03-07 12:25:47 +01:00

28 lines
1.2 KiB
Bash

#!/bin/sh
# shellcheck shell=sh
set -e
CONFIG_PATH="/data/options.json"
# Use the host BlueZ via D-Bus (requires host_dbus: true in config.yaml)
export DBUS_SYSTEM_BUS_ADDRESS="unix:path=/run/dbus/system_bus_socket"
# Read add-on options from the HA-provided JSON file using Python (already installed).
PORT=$(python3 -c "import json; d=json.load(open('${CONFIG_PATH}')); print(d.get('port', 8765))")
TRANSPORT=$(python3 -c "import json; d=json.load(open('${CONFIG_PATH}')); print(d.get('transport', 'ble'))")
CHANNEL=$(python3 -c "import json; d=json.load(open('${CONFIG_PATH}')); print(d.get('channel', 1))")
BLE_ADDRESS=$(python3 -c "import json; d=json.load(open('${CONFIG_PATH}')); print(d.get('ble_address') or '')")
export FICHERO_TRANSPORT="${TRANSPORT}"
export FICHERO_CHANNEL="${CHANNEL}"
if [ -n "${BLE_ADDRESS}" ]; then
export FICHERO_ADDR="${BLE_ADDRESS}"
echo "[fichero] Using fixed Bluetooth address: ${BLE_ADDRESS}"
else
echo "[fichero] No address configured - will auto-scan for printer on first request."
fi
echo "[fichero] Starting Fichero Printer API on 0.0.0.0:${PORT} (transport: ${TRANSPORT})..."
exec uvicorn fichero.api:app --host 0.0.0.0 --port "${PORT}"