mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 02:11:01 +01:00
GitHub bot: fix linting issues (nobuild)
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
# shellcheck shell=bash
|
||||
set -euo pipefail
|
||||
|
||||
slug="${HOSTNAME/-/_}" ; slug="${slug#*_}"
|
||||
slug="${HOSTNAME/-/_}"
|
||||
slug="${slug#*_}"
|
||||
|
||||
# CONFIG FILE
|
||||
if [[ ! -f /config/configuration.yaml && ! -f /config/configuration.json ]]; then
|
||||
@@ -19,8 +20,8 @@ if bashio::config.has_value 'CONFIG_LOCATION'; then
|
||||
[[ "$CONFIGSOURCE" == *.* ]] && CONFIGSOURCE="$(dirname "$CONFIGSOURCE")"
|
||||
[[ "$CONFIGSOURCE" != *.yaml ]] && CONFIGSOURCE="${CONFIGSOURCE%/}/config.yaml"
|
||||
case "$CONFIGSOURCE" in
|
||||
/share/*|/config/*|/data/*) :;;
|
||||
*) bashio::log.red "CONFIG_LOCATION must be in /share, /config or /data – reverting." && CONFIGSOURCE="$CONFIGLOCATION/config.yaml";;
|
||||
/share/* | /config/* | /data/*) : ;;
|
||||
*) bashio::log.red "CONFIG_LOCATION must be in /share, /config or /data – reverting." && CONFIGSOURCE="$CONFIGLOCATION/config.yaml" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -31,8 +32,10 @@ fi
|
||||
|
||||
chmod -R 755 "$(dirname "$CONFIGSOURCE")"
|
||||
|
||||
HAS_PYTHON=false; command -v python3 &>/dev/null && HAS_PYTHON=true
|
||||
HAS_YQ=false; command -v yq &>/dev/null && HAS_YQ=true
|
||||
HAS_PYTHON=false
|
||||
command -v python3 &>/dev/null && HAS_PYTHON=true
|
||||
HAS_YQ=false
|
||||
command -v yq &>/dev/null && HAS_YQ=true
|
||||
|
||||
$HAS_PYTHON || bashio::log.yellow "python3 not found – /env.py export disabled."
|
||||
$HAS_YQ || bashio::exit.nok "yq not found – script not executed."
|
||||
@@ -79,7 +82,8 @@ while IFS= read -r LINE; do
|
||||
VALUE="$(get_secret "$NAME")"
|
||||
[[ -z "$VALUE" ]] && bashio::exit.nok "Secret '$NAME' not found in $SECRETSFILE"
|
||||
fi
|
||||
VALUE="${VALUE##[[:space:]]}" ; VALUE="${VALUE%%[[:space:]]}"
|
||||
VALUE="${VALUE##[[:space:]]}"
|
||||
VALUE="${VALUE%%[[:space:]]}"
|
||||
SAFE_VALUE=$(shell_escape "$VALUE")
|
||||
export "$KEY=$VALUE"
|
||||
if $HAS_PYTHON; then
|
||||
@@ -95,14 +99,14 @@ os.environ[k] = v
|
||||
PY
|
||||
fi
|
||||
env_val=$(dq_escape "$VALUE")
|
||||
printf '%s="%s"\n' "$KEY" "$env_val" >> /.env
|
||||
printf '%s="%s"\n' "$KEY" "$env_val" >> /etc/environment
|
||||
[[ -d /var/run/s6/container_environment ]] && printf '%s' "$VALUE" > "/var/run/s6/container_environment/$KEY"
|
||||
printf '%s="%s"\n' "$KEY" "$env_val" >>/.env
|
||||
printf '%s="%s"\n' "$KEY" "$env_val" >>/etc/environment
|
||||
[[ -d /var/run/s6/container_environment ]] && printf '%s' "$VALUE" >"/var/run/s6/container_environment/$KEY"
|
||||
for script in /etc/services.d/*/*run* /etc/cont-init.d/*run*; do
|
||||
[[ -f $script ]] || continue
|
||||
grep -q "^export $KEY=" "$script" || sed -i "1i export $KEY=$SAFE_VALUE" "$script"
|
||||
done
|
||||
grep -q "^export $KEY=" ~/.bashrc || echo "export $KEY=$SAFE_VALUE" >> ~/.bashrc
|
||||
grep -q "^export $KEY=" ~/.bashrc || echo "export $KEY=$SAFE_VALUE" >>~/.bashrc
|
||||
bashio::log.blue "$KEY='${VALUE:0:60}'${VALUE:60:+…}"
|
||||
done < <(read_config "$CONFIGSOURCE")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user