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() {