mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-13 11:21:02 +01:00
Update 91-secrets.sh
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user