From d6822a6a074cbe433f0778f6d9d4bc4b32c72fd7 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 5 Dec 2021 19:51:02 +0100 Subject: [PATCH] Create 00-global_var.sh --- webtop/root/etc/cont-init.d/00-global_var.sh | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 webtop/root/etc/cont-init.d/00-global_var.sh diff --git a/webtop/root/etc/cont-init.d/00-global_var.sh b/webtop/root/etc/cont-init.d/00-global_var.sh new file mode 100644 index 000000000..448527a43 --- /dev/null +++ b/webtop/root/etc/cont-init.d/00-global_var.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +################################### +# 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//[\"\']/} &>/dev/null" + # Use locally + export $line + # Export the variable to run scripts + sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* +done + +################ +# Set timezone # +################ +if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then + if [ -f /usr/share/zoneinfo/$TZ ]; then + echo "Timezone set from $(cat /etc/timezone) to $TZ" + ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone + fi +fi