Files
Fichero/fichero_printer/run.sh
Tobias Leuschner 218b3c4961
Some checks failed
Deploy to GitHub Pages / build (push) Has been cancelled
Deploy to GitHub Pages / deploy (push) Has been cancelled
fix: use python:3.12-alpine3.21 from Docker Hub, rewrite run.sh without bashio
2026-03-07 12:08:34 +01:00

25 lines
1.0 KiB
Bash

#!/bin/sh
# shellcheck shell=sh
set -e
CONFIG_PATH="/data/options.json"
# 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}"