From 87256bb15582d9ec33c8eb186a6b95d2699ba0a4 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 10 Mar 2022 11:47:11 +0100 Subject: [PATCH] Update 99-run.sh --- zoneminder/rootfs/etc/cont-init.d/99-run.sh | 30 ++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/zoneminder/rootfs/etc/cont-init.d/99-run.sh b/zoneminder/rootfs/etc/cont-init.d/99-run.sh index f2234a946..25066d4cb 100644 --- a/zoneminder/rootfs/etc/cont-init.d/99-run.sh +++ b/zoneminder/rootfs/etc/cont-init.d/99-run.sh @@ -2,15 +2,39 @@ # shellcheck shell=bash # hadolint ignore=SC2155 -sleep 1000000 +################################### +# Export all addon options as env # +################################### + +# For all keys in options.json +JSONSOURCE="/data/options.json" + +# Export keys as env variables +# echo "All addon options were exported as variables" +mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}") + +for KEYS in "${arr[@]}"; do + # export key + VALUE=$(jq ."$KEYS" "${JSONSOURCE}") + line="${KEYS}='${VALUE//[\"\']/}'" + # Use locally + if [[ "${KEYS}" == *"PASS"* ]]; then + bashio::log.blue "${KEYS}=******" + else + bashio::log.blue "$line" + fi + # Export the variable to run scripts + export $line + if cat /etc/services.d/*/*run* &>/dev/null; then sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null; fi + if cat /etc/cont-init.d/*run* &>/dev/null; then sed -i "1a export $line" /etc/cont-init.d/*run* 2>/dev/null; fi +done ################### # Define database # ################### bashio::log.info "Defining database" -DBTYPE=$(bashio::config 'DB_CONNECTION') -case "$DBTYPE" in +case "$DB_CONNECTION" in # Use MariaDB mariadb_addon)