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

@@ -44,9 +44,9 @@ for KEYS in "${arr[@]}"; do
export "${KEYS}='${VALUE}'"
# set .env
echo "$KEYS=\"$VALUE\"" >> /.env || true
# set /etc/environmemt
# set /etc/environment
mkdir -p /etc
echo "$KEYS=$VALUE" >> /etc/environmemt
echo "$KEYS=$VALUE" >> /etc/environment
# For non s6
if cat /etc/services.d/*/*run* &>/dev/null; then sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null; fi
if cat /etc/cont-init.d/*run* &>/dev/null; then sed -i "1a export $line" /etc/cont-init.d/*run* 2>/dev/null; fi

View File

@@ -138,6 +138,20 @@ if bashio::config.has_value 'networkdisks'; then
SMBVERS="$(nmap --script smb-protocols "$server" -p 445 2>1 | awk '/ [0-9]/' | awk '{print $NF}' | cut -c -3 | sort -V | tail -n 1 || true)"
# Manage output
if [ -n "$SMBVERS" ]; then
case $SMBVERS in
202)
SMBVERS="2.0"
;;
21)
SMBVERS="2.1"
;;
302)
SMBVERS="3.02"
;;
311)
SMBVERS="3.1.1"
;;
esac
echo "... SMB version $SMBVERS detected"
SMBVERS=",vers=$SMBVERS"
elif smbclient -t 2 -L "$server" -m NT1 -N $DOMAINCLIENT &>/dev/null; then

View File

@@ -8,10 +8,22 @@ set -e
##################
# Exit if /config is not mounted
if [ ! -f /config/configuration.yaml ] || [ ! -d /config/.storage ]; then
if [ ! -d /config ]; then
exit 0
fi
# Define slug if
slug="${HOSTNAME#*-}"
# Check type of config folder
if [ ! -f /config/configuration.yaml ] && [ ! -f /config/configuration.json ]; then
# New config location
CONFIGLOCATION="/config"
else
# Legacy config location
CONFIGLOCATION="/config/addons_config/${slug}"
fi
# Where is the config
if bashio::config.has_value 'CONFIG_LOCATION'; then
@@ -29,14 +41,27 @@ if bashio::config.has_value 'CONFIG_LOCATION'; then
fi
done
if [ -z "$LOCATIONOK" ]; then
CONFIGSOURCE=/config/addons_config/${HOSTNAME#*-}
CONFIGSOURCE="$CONFIGLOCATION"
bashio::log.red "Watch-out : your CONFIG_LOCATION values can only be set in /share, /config or /data (internal to addon). It will be reset to the default location : $CONFIGSOURCE"
fi
else
# Use default
CONFIGSOURCE="/config/addons_config/${HOSTNAME#*-}/config.yaml"
CONFIGSOURCE="$CONFIGLOCATION/config.yaml"
fi
# Migrate if needed
if [ "$CONFIGLOCATION" == "/config" ]; then
# Migrate file
if [ -f "/homeassistant/addons_config/${slug}/config.yaml" ]; then
echo "Migrating config.yaml to new config location"
mv /homeassistant/addons_config/"${slug}"/config.yaml /config/config.yaml
fi
# Migrate option
if [[ "$(bashio::config "CONFIG_LOCATION")" == "/config/addons_config"* ]] && [ -f /config/config.yaml ]; then
bashio::addon.option "CONFIG_LOCATION" "/config/config.yaml"
CONFIGSOURCE="$(bashio::config "CONFIG_LOCATION")"
fi
fi
# Permissions
@@ -120,13 +145,13 @@ while IFS= read -r line; do
# Check if secret
if [[ "${line}" == *'!secret '* ]]; then
echo "secret detected"
secret=${line#*secret }
secret="${line#*secret }"
# Check if single match
secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml)
secretnum="$(sed -n "/$secret:/=" /config/secrets.yaml)"
[[ $(echo $secretnum) == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file"
# Get text
secret=$(sed -n "/$secret:/p" /config/secrets.yaml)
secret=${secret#*: }
secret="$(sed -n "/$secret:/p" /config/secrets.yaml)"
secret="${secret#*: }"
line="${line%%=*}='$secret'"
fi
# Data validation
@@ -144,7 +169,7 @@ while IFS= read -r line; do
# set .env
if [ -f /.env ]; then echo "$KEYS=$VALUE" >> /.env; fi
mkdir -p /etc
echo "$KEYS=$VALUE" >> /etc/environmemt
echo "$KEYS=$VALUE" >> /etc/environment
# Export to scripts
if cat /etc/services.d/*/*run* &>/dev/null; then sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null; fi
if cat /etc/cont-init.d/*run* &>/dev/null; then sed -i "1a export $line" /etc/cont-init.d/*run* 2>/dev/null; fi

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