mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-08-01 02:40:31 +02:00
Update 01-custom_script.sh
This commit is contained in:
@@ -22,18 +22,30 @@ else
|
|||||||
mkdir -p /config/addons_autoscripts
|
mkdir -p /config/addons_autoscripts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bashio::log.green "Execute $CONFIGLOCATION/${slug}.sh if existing"
|
bashio::log.green "Execute $CONFIGFILEBROWSER/${slug}.sh if existing"
|
||||||
bashio::log.green "---------------------------------------------------------"
|
|
||||||
bashio::log.green "If accessing the file with filebrowser it should be mapped to $CONFIGFILEBROWSER/${slug}.sh"
|
|
||||||
bashio::log.green "Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add-ons-feature-:-customisation"
|
bashio::log.green "Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add-ons-feature-:-customisation"
|
||||||
|
|
||||||
# Execute scripts
|
# Download template if no script found and exit
|
||||||
if [ -f "$CONFIGLOCATION/${slug}".sh ]; then
|
if [ ! -f "$CONFIGLOCATION/${slug}".sh ]; then
|
||||||
bashio::log.green "... script found, executing"
|
TEMPLATESOURCE="https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/script.template"
|
||||||
# Convert scripts to linux
|
curl -f -L -s -S "$TEMPLATESOURCE" --output "$CONFIGLOCATION/${slug}".sh
|
||||||
dos2unix "$CONFIGLOCATION/${slug}".sh || true
|
exit 0
|
||||||
chmod +x "$CONFIGLOCATION/${slug}".sh || true
|
|
||||||
/."$CONFIGLOCATION/${slug}".sh
|
|
||||||
else
|
|
||||||
bashio::log.green "... no script found, exiting"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Convert scripts to linux
|
||||||
|
dos2unix "$CONFIGLOCATION/${slug}".sh &>/dev/null || true
|
||||||
|
chmod +x "$CONFIGLOCATION/${slug}".sh
|
||||||
|
|
||||||
|
# Check if there is actual commands
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
# Remove leading and trailing whitespaces
|
||||||
|
line=$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
|
|
||||||
|
# Check if line is not empty and does not start with #
|
||||||
|
if [[ -n "$line" ]] && [[ ! "$line" =~ ^# ]]; then
|
||||||
|
bashio::log.green "... script found, executing"
|
||||||
|
/."$CONFIGLOCATION/${slug}".sh
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done < "$CONFIGLOCATION/${slug}".sh
|
||||||
|
|||||||
Reference in New Issue
Block a user