This commit is contained in:
Alexandre
2023-11-21 09:53:56 +01:00
parent 2e6e4693a7
commit 8e035dde96
350 changed files with 1908 additions and 1328 deletions

View File

@@ -2,26 +2,35 @@
# shellcheck shell=bash
set -e
# Define slug if needed
slug="${HOSTNAME#*-}"
bashio::log.green "Execute /config/addons_autoscripts/${slug}.sh if existing"
# Check type of config folder
if [ ! -f /config/configuration.yaml ] && [ ! -f /config/configuration.json ]; then
# Migrate previous script
if [ -f /homeassistant/addons_autoscripts/"${slug}".sh ]; then
echo "Migrating scripts to new config location"
mv -f /homeassistant/addons_autoscripts/"${slug}".sh /config/"${slug}".sh
fi
# New config location
CONFIGLOCATION="/config"
else
# Legacy config location
CONFIGLOCATION="/config/addons_autoscripts"
mkdir -p /config/addons_autoscripts
fi
bashio::log.green "Execute $CONFIGLOCATION/${slug}.sh if existing"
bashio::log.green "---------------------------------------------------------"
echo "Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add-ons-feature-:-customisation"
mkdir -p /config/addons_autoscripts
# Migrate scripts
if [ -f /config/"${slug}".sh ]; then
mv -f /config/"${slug}".sh /config/addons_autoscripts/"${slug}".sh
fi
# Execute scripts
if [ -f /config/addons_autoscripts/"${slug}".sh ]; then
if [ -f "$CONFIGLOCATION/${slug}".sh ]; then
bashio::log.green "... script found, executing"
# Convert scripts to linux
dos2unix /config/addons_autoscripts/"${slug}".sh || true
chmod +x /config/addons_autoscripts/"${slug}".sh || true
/./config/addons_autoscripts/"${slug}".sh
dos2unix "$CONFIGLOCATION/${slug}".sh || true
chmod +x "$CONFIGLOCATION/${slug}".sh || true
/."$CONFIGLOCATION/${slug}".sh
else
bashio::log.green "... no script found, exiting"
fi