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