mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-23 17:21:56 +02:00
Update 91-secrets.sh
This commit is contained in:
@@ -10,7 +10,23 @@ set_option() {
|
|||||||
local key="$1"
|
local key="$1"
|
||||||
local value="$2"
|
local value="$2"
|
||||||
|
|
||||||
|
# Store permanently in Home Assistant add-on options
|
||||||
bashio::addon.option "${key}" "${value}"
|
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}"
|
export "${key}=${value}"
|
||||||
|
|
||||||
if [ -d /var/run/s6/container_environment ]; then
|
if [ -d /var/run/s6/container_environment ]; then
|
||||||
@@ -20,13 +36,10 @@ set_option() {
|
|||||||
|
|
||||||
for key in MEILI_MASTER_KEY NEXTAUTH_SECRET; do
|
for key in MEILI_MASTER_KEY NEXTAUTH_SECRET; do
|
||||||
if bashio::config.has_value "${key}"; then
|
if bashio::config.has_value "${key}"; then
|
||||||
value="$(bashio::config "${key}")"
|
bashio::log.info "Using existing ${key}"
|
||||||
export "${key}=${value}"
|
load_option "${key}"
|
||||||
if [ -d /var/run/s6/container_environment ]; then
|
|
||||||
printf "%s" "${value}" > "/var/run/s6/container_environment/${key}"
|
|
||||||
fi
|
|
||||||
else
|
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)"
|
value="$(generate_secret)"
|
||||||
set_option "${key}" "${value}"
|
set_option "${key}" "${value}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user