Merge pull request #2418 from alexbelgium/codex/fix-issue-#2416-in-hassio-addons

Fix Seafile env_vars export handling https://github.com/alexbelgium/hassio-addons/issues/2416
This commit is contained in:
Alexandre
2026-01-30 16:58:13 +01:00
committed by GitHub
3 changed files with 33 additions and 1 deletions

View File

@@ -1,4 +1,7 @@
## 12.0.18 (2026-03-20)
- Fix `env_vars` handling so extra environment variables are exported correctly.
## 12.0.17 (2026-03-12)
- Ensure `SERVICE_URL` and `FILE_SERVER_ROOT` are written to the active Seafile config path.

View File

@@ -128,5 +128,5 @@ services:
slug: seafile
udev: true
url: https://github.com/alexbelgium/hassio-addons/tree/master/seafile
version: "12.0.17"
version: "12.0.18"
webui: http://[HOST]:[PORT:8000]

View File

@@ -17,6 +17,9 @@ JSONSOURCE="/data/options.json"
mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}")
for KEYS in "${arr[@]}"; do
if [[ "${KEYS}" == "env_vars" ]]; then
continue
fi
# export key
VALUE=$(jq ."$KEYS" "${JSONSOURCE}")
line="${KEYS}='${VALUE//[\"\']/}'"
@@ -33,6 +36,32 @@ for KEYS in "${arr[@]}"; do
find /opt/seafile -name '*.sh' -print0 | xargs -0 sed -i "1a export $line"
done
#######################################
# Apply extra environment variables #
#######################################
if jq -e '.env_vars? | length > 0' "${JSONSOURCE}" >/dev/null; then
bashio::log.info "Applying env_vars"
while IFS=$'\t' read -r ENV_NAME ENV_VALUE; do
if [[ -z "${ENV_NAME}" || "${ENV_NAME}" == "null" ]]; then
continue
fi
if bashio::config.false "verbose" || [[ "${ENV_NAME}" == *"PASS"* ]]; then
bashio::log.blue "${ENV_NAME}=******"
else
bashio::log.blue "${ENV_NAME}=${ENV_VALUE}"
fi
export "${ENV_NAME}=${ENV_VALUE}"
ENV_VALUE_ESCAPED=$(printf "%q" "${ENV_VALUE}")
ENV_LINE="export ${ENV_NAME}=${ENV_VALUE_ESCAPED}"
sed -i "1a ${ENV_LINE}" /home/seafile/*.sh 2>/dev/null
find /opt/seafile -name '*.sh' -print0 | xargs -0 sed -i "1a ${ENV_LINE}"
done < <(jq -r '.env_vars[] | [.name, .value] | @tsv' "${JSONSOURCE}")
fi
#################
# DATA_LOCATION #
#################