fix: use python:3.12-alpine3.21 from Docker Hub, rewrite run.sh without bashio
This commit is contained in:
@@ -1,29 +1,24 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
#!/bin/sh
|
||||
# shellcheck shell=sh
|
||||
set -e
|
||||
|
||||
declare port
|
||||
declare ble_address
|
||||
declare transport
|
||||
declare channel
|
||||
CONFIG_PATH="/data/options.json"
|
||||
|
||||
port=$(bashio::config 'port')
|
||||
transport=$(bashio::config 'transport')
|
||||
channel=$(bashio::config 'channel')
|
||||
# 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 '')")
|
||||
|
||||
# Pass connection settings to the Python module via environment variables.
|
||||
# The module reads these at import time, so they must be exported before uvicorn
|
||||
# imports fichero.api.
|
||||
export FICHERO_TRANSPORT="${transport}"
|
||||
export FICHERO_CHANNEL="${channel}"
|
||||
export FICHERO_TRANSPORT="${TRANSPORT}"
|
||||
export FICHERO_CHANNEL="${CHANNEL}"
|
||||
|
||||
ble_address=$(bashio::config 'ble_address')
|
||||
if [ -n "${ble_address}" ]; then
|
||||
export FICHERO_ADDR="${ble_address}"
|
||||
bashio::log.info "Using fixed Bluetooth address: ${ble_address}"
|
||||
if [ -n "${BLE_ADDRESS}" ]; then
|
||||
export FICHERO_ADDR="${BLE_ADDRESS}"
|
||||
echo "[fichero] Using fixed Bluetooth address: ${BLE_ADDRESS}"
|
||||
else
|
||||
bashio::log.info "No address configured – will auto-scan for printer on first request."
|
||||
echo "[fichero] No address configured - will auto-scan for printer on first request."
|
||||
fi
|
||||
|
||||
bashio::log.info "Starting Fichero Printer API on 0.0.0.0:${port} (transport: ${transport})..."
|
||||
exec uvicorn fichero.api:app --host 0.0.0.0 --port "${port}"
|
||||
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}"
|
||||
|
||||
Reference in New Issue
Block a user