mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-05 00:24:58 +02:00
Restore
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user