mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-02 05:44:03 +02:00
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:
@@ -7,12 +7,15 @@ set -e
|
|||||||
# ======================================================================
|
# ======================================================================
|
||||||
|
|
||||||
if ! bashio::supervisor.ping 2>/dev/null; then
|
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 '-----------------------------------------------------------'
|
||||||
bashio::log.blue "Starting addon in standalone mode (no Supervisor)"
|
bashio::log.blue "Starting addon in standalone mode (no Supervisor)"
|
||||||
bashio::log.blue "Version : ${BUILD_VERSION:-1.0}"
|
bashio::log.blue "Version : ${BUILD_VERSION:-1.0}"
|
||||||
bashio::log.blue "Config source: ENV + /data/options.json"
|
bashio::log.blue "Config source: ENV + /data/options.json"
|
||||||
bashio::log.blue '-----------------------------------------------------------'
|
bashio::log.blue '-----------------------------------------------------------'
|
||||||
source /usr/local/lib/bashio-standalone.sh
|
|
||||||
cp -rf /usr/local/lib/bashio-standalone.sh /usr/bin/bashio
|
cp -rf /usr/local/lib/bashio-standalone.sh /usr/bin/bashio
|
||||||
grep -rlZ "^#!.*bashio" /etc |
|
grep -rlZ "^#!.*bashio" /etc |
|
||||||
while IFS= read -r -d '' f; do
|
while IFS= read -r -d '' f; do
|
||||||
|
|||||||
@@ -64,7 +64,20 @@ if ! command -v bashio::addon.version >/dev/null 2>&1; then
|
|||||||
done
|
done
|
||||||
fi
|
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() {
|
validate_shebang() {
|
||||||
@@ -133,7 +146,7 @@ fi
|
|||||||
sed -i "1s|^.*|#!$shebang|" "$0"
|
sed -i "1s|^.*|#!$shebang|" "$0"
|
||||||
|
|
||||||
if ! command -v bashio::addon.version >/dev/null 2>&1; then
|
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
|
if [ -f "$f" ]; then
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
. "$f"
|
. "$f"
|
||||||
|
|||||||
@@ -83,7 +83,21 @@ if ! command -v bashio::addon.version >/dev/null 2>&1; then
|
|||||||
done
|
done
|
||||||
fi
|
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() {
|
validate_shebang() {
|
||||||
|
|||||||
Reference in New Issue
Block a user