From 9b6785a9aa7963508c6a61178946d4e06ab2b986 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Tue, 9 Jan 2024 22:13:02 +0100 Subject: [PATCH] Correct shebang for custom scripts --- .templates/01-custom_script.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.templates/01-custom_script.sh b/.templates/01-custom_script.sh index b95d77e2a..ac1901614 100755 --- a/.templates/01-custom_script.sh +++ b/.templates/01-custom_script.sh @@ -44,6 +44,13 @@ fi dos2unix "$CONFIGSOURCE" &>/dev/null || true chmod +x "$CONFIGSOURCE" +# Get current shebang, if not available use another +currentshebang="$(sed -n '1{s/^#![[:blank:]]*//p;q}' "$CONFIGSOURCE")" +if [ ! -f "${currentshebang%% *}" ]; then + for shebang in "/command/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/bin/bash" "/bin/sh"; do if [ -f "${shebang%% *}" ]; then break; fi; done + sed -i "s|$currentshebang|$shebang|g" "$CONFIGSOURCE" +fi + # Check if there is actual commands while IFS= read -r line do