mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-09 00:55:58 +02:00
Update ha_entrypoint.sh
This commit is contained in:
@@ -28,30 +28,16 @@ run_script() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get current shebang, if not available use another
|
# Get current shebang, if not available use another
|
||||||
currentshebang="$(sed -n '1{s/^#![[:space:]]*//p;q}' "$runfile")"
|
currentshebang="$(sed -n '1{s/^#![[:blank:]]*//p;q}' "$SCRIPTS")"
|
||||||
interp="${currentshebang%% *}"
|
if [ ! -f "${currentshebang%% *}" ]; then
|
||||||
|
for shebang in "/command/with-contenv bashio" "/usr/bin/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/usr/bin/bash" "/usr/bin/sh" "/bin/bash" "/bin/sh"; do
|
||||||
if [ -z "$currentshebang" ] || [ ! -x "$interp" ]; then
|
command_path="${shebang%% *}"
|
||||||
for candidate in \
|
if [ -x "$command_path" ] && "$command_path" echo "yes" > /dev/null 2>&1; then
|
||||||
"/command/with-contenv bashio" \
|
echo "Valid shebang: $shebang"
|
||||||
"/usr/bin/with-contenv bashio" \
|
|
||||||
"/usr/bin/env bashio" \
|
|
||||||
"/usr/bin/bashio" \
|
|
||||||
"/usr/bin/bash" "/usr/bin/sh" "/bin/bash" "/bin/sh"
|
|
||||||
do
|
|
||||||
cmd="${candidate%% *}"
|
|
||||||
if [ -x "$cmd" ]; then
|
|
||||||
new_shebang="$candidate"
|
|
||||||
echo "Valid shebang: $new_shebang"
|
|
||||||
# Replace only the first line
|
|
||||||
if [ -n "$currentshebang" ]; then
|
|
||||||
sed -i "1s|.*|#!${new_shebang}|" "$runfile"
|
|
||||||
else
|
|
||||||
sed -i "1i#!"${new_shebang} "$runfile"
|
|
||||||
fi
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
sed -i "s|$currentshebang|$shebang|g" "$SCRIPTS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use source to share env variables when requested
|
# Use source to share env variables when requested
|
||||||
|
|||||||
Reference in New Issue
Block a user