28 lines
1.2 KiB
Bash
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}"
|