mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-07 06:28:48 +02:00
GitHub bot: fix linting issues (nobuild)
This commit is contained in:
@@ -28,75 +28,75 @@ fi
|
|||||||
mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}")
|
mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}")
|
||||||
|
|
||||||
for KEYS in "${arr[@]}"; do
|
for KEYS in "${arr[@]}"; do
|
||||||
# export key
|
# export key
|
||||||
VALUE=$(jq -r --raw-output ".\"$KEYS\"" "$JSONSOURCE")
|
VALUE=$(jq -r --raw-output ".\"$KEYS\"" "$JSONSOURCE")
|
||||||
|
|
||||||
# Check if the value is an array
|
# Check if the value is an array
|
||||||
if [[ "$VALUE" == \[* ]]; then
|
if [[ "$VALUE" == \[* ]]; then
|
||||||
bashio::log.warning "One of your options is an array, skipping"
|
bashio::log.warning "One of your options is an array, skipping"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if secret
|
# Check if secret
|
||||||
if [[ "$VALUE" == *"!secret "* ]]; then
|
if [[ "$VALUE" == *"!secret "* ]]; then
|
||||||
echo "secret detected"
|
echo "secret detected"
|
||||||
# Get argument
|
# Get argument
|
||||||
secret=${VALUE#*secret }
|
secret=${VALUE#*secret }
|
||||||
# Remove trailing ' or "
|
# Remove trailing ' or "
|
||||||
secret="${secret%[\"\']}"
|
secret="${secret%[\"\']}"
|
||||||
# Stop if secret file not mounted
|
# Stop if secret file not mounted
|
||||||
if [[ "$SECRETSOURCE" == "false" ]]; then
|
if [[ "$SECRETSOURCE" == "false" ]]; then
|
||||||
bashio::log.warning "Homeassistant config not mounted, secrets are not supported"
|
bashio::log.warning "Homeassistant config not mounted, secrets are not supported"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# Check if single match
|
# Check if single match
|
||||||
secretnum=$(sed -n "/$secret:/=" "$SECRETSOURCE")
|
secretnum=$(sed -n "/$secret:/=" "$SECRETSOURCE")
|
||||||
[[ "$secretnum" == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file"
|
[[ "$secretnum" == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file"
|
||||||
# Get text
|
# Get text
|
||||||
secret=$(sed -n "/$secret:/p" "$SECRETSOURCE")
|
secret=$(sed -n "/$secret:/p" "$SECRETSOURCE")
|
||||||
secret=${secret#*: }
|
secret=${secret#*: }
|
||||||
VALUE="$secret"
|
VALUE="$secret"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Data validation and export
|
# Data validation and export
|
||||||
if [[ "$KEYS" =~ ^[^[:space:]]+$ ]]; then
|
if [[ "$KEYS" =~ ^[^[:space:]]+$ ]]; then
|
||||||
line="${KEYS}=${VALUE}"
|
line="${KEYS}=${VALUE}"
|
||||||
# Show in log
|
# Show in log
|
||||||
if bashio::config.false "verbose" || [[ "${KEYS,,}" == *"pass"* ]]; then
|
if bashio::config.false "verbose" || [[ "${KEYS,,}" == *"pass"* ]]; then
|
||||||
bashio::log.blue "${KEYS}=******"
|
bashio::log.blue "${KEYS}=******"
|
||||||
else
|
else
|
||||||
bashio::log.blue "$line"
|
bashio::log.blue "$line"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Export the variable to run scripts
|
# Export the variable to run scripts
|
||||||
export "$line"
|
export "$line"
|
||||||
|
|
||||||
# Export to python
|
# Export to python
|
||||||
if command -v "python3" &>/dev/null; then
|
if command -v "python3" &>/dev/null; then
|
||||||
[ ! -f /env.py ] && echo "import os" >/env.py
|
[ ! -f /env.py ] && echo "import os" >/env.py
|
||||||
# Escape single quotes in VALUE
|
# Escape single quotes in VALUE
|
||||||
VALUE_ESCAPED="${VALUE//\'/\'\"\'\"\'}"
|
VALUE_ESCAPED="${VALUE//\'/\'\"\'\"\'}"
|
||||||
echo "os.environ['${KEYS}'] = '${VALUE_ESCAPED}'" >>/env.py
|
echo "os.environ['${KEYS}'] = '${VALUE_ESCAPED}'" >>/env.py
|
||||||
python3 /env.py
|
python3 /env.py
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set .env
|
# Set .env
|
||||||
echo "$line" >>/.env || true
|
echo "$line" >>/.env || true
|
||||||
|
|
||||||
# Set /etc/environment
|
# Set /etc/environment
|
||||||
mkdir -p /etc
|
mkdir -p /etc
|
||||||
echo "$line" >>/etc/environment
|
echo "$line" >>/etc/environment
|
||||||
|
|
||||||
# For non s6
|
# 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/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
|
if cat /etc/cont-init.d/*run* &>/dev/null; then sed -i "1a export $line" /etc/cont-init.d/*run* 2>/dev/null; fi
|
||||||
|
|
||||||
# For s6
|
# For s6
|
||||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" >/var/run/s6/container_environment/"${KEYS}"; fi
|
if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" >/var/run/s6/container_environment/"${KEYS}"; fi
|
||||||
echo "export ${KEYS}='${VALUE}'" >>~/.bashrc
|
echo "export ${KEYS}='${VALUE}'" >>~/.bashrc
|
||||||
else
|
else
|
||||||
bashio::log.red "Skipping line that does not follow the correct structure: $line"
|
bashio::log.red "Skipping line that does not follow the correct structure: $line"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
################
|
################
|
||||||
|
|||||||
Reference in New Issue
Block a user