From 0ae38f2fa42bc3991e2f51010867c14489398056 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sat, 2 Aug 2025 12:41:07 +0200 Subject: [PATCH] Direct update --- .templates/ha_entrypoint.sh | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/.templates/ha_entrypoint.sh b/.templates/ha_entrypoint.sh index 6f0b99c5c..115b65124 100755 --- a/.templates/ha_entrypoint.sh +++ b/.templates/ha_entrypoint.sh @@ -26,35 +26,26 @@ candidate_shebangs+=( "/usr/bin/env bashio" "/usr/bin/bashio" "/usr/bin/bash" + "/usr/bin/sh" "/bin/bash" "/bin/sh" ) -# Find the first valid shebang interpreter in candidate list by probing bashio::addon.version +# Find the first valid shebang interpreter in candidate list shebang="" -tmp="$(mktemp)" -trap 'rm -f "$tmp"' EXIT - for candidate in "${candidate_shebangs[@]}"; do - echo "Trying $candidate" - # Build a tiny probe script that prints the addon version - printf '#!%s\n' "$candidate" >"$tmp" - cat >>"$tmp" <<'EOF' -out="$(bashio::addon.version 2>/dev/null || true)" -[ -n "$out" ] && printf '%s\n' "$out" -EOF - chmod +x "$tmp" - - # Run the probe and check for at least one digit in the output - out="$(exec "$tmp" 2>/dev/null || true)" - if printf '%s' "$out" | grep -qE '[0-9]'; then - shebang="$candidate" - break + command_path="${candidate%% *}" + # Test if command exists and can actually execute a shell command (for shells) + if [ -x "$command_path" ]; then + # Try as both 'sh -c' and 'bashio echo' style + if "$command_path" -c 'echo yes' >/dev/null 2>&1 || "$command_path" echo "yes" >/dev/null 2>&1; then + shebang="$candidate" + break + fi fi done - if [ -z "$shebang" ]; then - echo "ERROR: No valid shebang found!" >&2 + echo "ERROR: No valid shebang found!" exit 1 fi