Fix standalone Docker Compose mode: fallback to bashio-standalone when no Supervisor

- ha_entrypoint.sh: probe_script_content now tries regular bashio first,
  falls back to bashio-standalone.sh if Supervisor API unreachable
- 00-banner.sh: source bashio-standalone before calling bashio functions
  in standalone branch (prevents undefined function errors with set -e)
- 01-custom_script.sh: same probe fix + add bashio-standalone.sh to
  fallback source chain

Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-25 16:43:19 +00:00
parent bfce7f4ebd
commit 2f9721e0d7
3 changed files with 34 additions and 4 deletions

View File

@@ -7,12 +7,15 @@ set -e
# ======================================================================
if ! bashio::supervisor.ping 2>/dev/null; then
# Source standalone bashio first to provide function definitions
if [ -f /usr/local/lib/bashio-standalone.sh ]; then
source /usr/local/lib/bashio-standalone.sh
fi
bashio::log.blue '-----------------------------------------------------------'
bashio::log.blue "Starting addon in standalone mode (no Supervisor)"
bashio::log.blue "Version : ${BUILD_VERSION:-1.0}"
bashio::log.blue "Config source: ENV + /data/options.json"
bashio::log.blue '-----------------------------------------------------------'
source /usr/local/lib/bashio-standalone.sh
cp -rf /usr/local/lib/bashio-standalone.sh /usr/bin/bashio
grep -rlZ "^#!.*bashio" /etc |
while IFS= read -r -d '' f; do

View File

@@ -64,7 +64,20 @@ if ! command -v bashio::addon.version >/dev/null 2>&1; then
done
fi
bashio::addon.version
# Try regular bashio, fallback to standalone if unavailable or fails
set +e
_bv="$(bashio::addon.version 2>/dev/null)"
_rc=$?
set -e
if [ "$_rc" -ne 0 ] || [ -z "$_bv" ] || [ "$_bv" = "null" ]; then
if [ -f /usr/local/lib/bashio-standalone.sh ]; then
. /usr/local/lib/bashio-standalone.sh
_bv="$(bashio::addon.version)"
fi
fi
echo "$_bv"
'
validate_shebang() {
@@ -133,7 +146,7 @@ fi
sed -i "1s|^.*|#!$shebang|" "$0"
if ! command -v bashio::addon.version >/dev/null 2>&1; then
for f in /usr/lib/bashio/bashio.sh /usr/lib/bashio/lib.sh /usr/src/bashio/bashio.sh /usr/local/lib/bashio/bashio.sh; do
for f in /usr/lib/bashio/bashio.sh /usr/lib/bashio/lib.sh /usr/src/bashio/bashio.sh /usr/local/lib/bashio/bashio.sh /usr/local/lib/bashio-standalone.sh; do
if [ -f "$f" ]; then
# shellcheck disable=SC1090
. "$f"

View File

@@ -83,7 +83,21 @@ if ! command -v bashio::addon.version >/dev/null 2>&1; then
done
fi
bashio::addon.version
# Try regular bashio, fallback to standalone if unavailable or fails
set +e
_bv="$(bashio::addon.version 2>/dev/null)"
_rc=$?
set -e
if [ "$_rc" -ne 0 ] || [ -z "$_bv" ] || [ "$_bv" = "null" ]; then
if [ -f /usr/local/lib/bashio-standalone.sh ]; then
# shellcheck disable=SC1091
. /usr/local/lib/bashio-standalone.sh
_bv="$(bashio::addon.version)"
fi
fi
echo "$_bv"
'
validate_shebang() {