Update 91-secrets.sh

This commit is contained in:
Alexandre
2026-01-11 17:06:14 +01:00
committed by GitHub
parent 8c0ea30920
commit 25034e2e47

View File

@@ -10,7 +10,23 @@ set_option() {
local key="$1"
local value="$2"
# Store permanently in Home Assistant add-on options
bashio::addon.option "${key}" "${value}"
# Export into current process
export "${key}=${value}"
# Export into s6 so all services inherit it
if [ -d /var/run/s6/container_environment ]; then
printf "%s" "${value}" > "/var/run/s6/container_environment/${key}"
fi
}
load_option() {
local key="$1"
local value
value="$(bashio::config "${key}")"
export "${key}=${value}"
if [ -d /var/run/s6/container_environment ]; then
@@ -20,13 +36,10 @@ set_option() {
for key in MEILI_MASTER_KEY NEXTAUTH_SECRET; do
if bashio::config.has_value "${key}"; then
value="$(bashio::config "${key}")"
export "${key}=${value}"
if [ -d /var/run/s6/container_environment ]; then
printf "%s" "${value}" > "/var/run/s6/container_environment/${key}"
fi
bashio::log.info "Using existing ${key}"
load_option "${key}"
else
bashio::log.warning "${key} is not set. Generating a new value and storing it in addon options."
bashio::log.warning "${key} not set, generating persistent secret"
value="$(generate_secret)"
set_option "${key}" "${value}"
fi