From 2f9721e0d723970990fd17497fd2683ca2b08eb2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Feb 2026 16:43:19 +0000 Subject: [PATCH 2/2] 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> --- .templates/00-banner.sh | 5 ++++- .templates/01-custom_script.sh | 17 +++++++++++++++-- .templates/ha_entrypoint.sh | 16 +++++++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.templates/00-banner.sh b/.templates/00-banner.sh index 31e1280d2..5ecba7c1f 100755 --- a/.templates/00-banner.sh +++ b/.templates/00-banner.sh @@ -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 diff --git a/.templates/01-custom_script.sh b/.templates/01-custom_script.sh index a846cf7c3..a3a845491 100755 --- a/.templates/01-custom_script.sh +++ b/.templates/01-custom_script.sh @@ -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" diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index dad64da45..755418dee 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -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() {