Initialize .env in env export templates

This commit is contained in:
Alexandre
2025-12-27 10:16:44 +01:00
parent 54ec5df87d
commit ea25783a73
2 changed files with 12 additions and 2 deletions

View File

@@ -14,6 +14,11 @@ bashio::log.notice "Additional informations : https://github.com/alexbelgium/has
echo ""
JSONSOURCE="/data/options.json"
ENV_FILE="/.env"
if [[ ! -f "$ENV_FILE" ]]; then
printf '# Generated by 00-global_var.sh from %s\n' "$JSONSOURCE" > "$ENV_FILE"
fi
# Define secrets location (optional)
SECRETSOURCE=""
@@ -233,7 +238,7 @@ export_option() {
printf '%s' "${value}" > "/var/run/s6/container_environment/${key}"
fi
echo "${key}=$(dotenv_quote "$value")" >> "/.env" 2>/dev/null || true
echo "${key}=$(dotenv_quote "$value")" >> "$ENV_FILE" 2>/dev/null || true
mkdir -p /etc
echo "${key}=$(dotenv_quote "$value")" >> /etc/environment 2>/dev/null || true

View File

@@ -74,6 +74,11 @@ if [[ "$CONFIGSOURCE" != *".yaml" ]]; then
exit 1
fi
ENV_FILE="/.env"
if [[ ! -f "$ENV_FILE" ]]; then
printf '# Generated by 01-config_yaml.sh from %s\n' "$CONFIGSOURCE" > "$ENV_FILE"
fi
# Permissions only if the config file already exists
if [[ "$CONFIGSOURCE" == *".yaml" ]] && [ -f "$CONFIGSOURCE" ]; then
echo "Setting permissions for the config.yaml directory"
@@ -174,7 +179,7 @@ while IFS= read -r line; do
python3 /env.py
fi
# set .env
echo "$line" >> /.env
echo "$line" >> "$ENV_FILE"
# set environment
mkdir -p /etc
echo "$line" >> /etc/environment