From a5eb85a8fdf1ca637baac03a60f38f81d29c8bb3 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:55:56 +0100 Subject: [PATCH] Fix seafile env_vars export --- seafile/CHANGELOG.md | 3 +++ seafile/rootfs/etc/cont-init.d/99-run.sh | 29 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/seafile/CHANGELOG.md b/seafile/CHANGELOG.md index 11bda5a44..ed83def92 100644 --- a/seafile/CHANGELOG.md +++ b/seafile/CHANGELOG.md @@ -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. diff --git a/seafile/rootfs/etc/cont-init.d/99-run.sh b/seafile/rootfs/etc/cont-init.d/99-run.sh index 55320453e..c7985af08 100755 --- a/seafile/rootfs/etc/cont-init.d/99-run.sh +++ b/seafile/rootfs/etc/cont-init.d/99-run.sh @@ -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 # #################