From 1c3986f3fa61a23e90c864318faf58e64ae411fa Mon Sep 17 00:00:00 2001 From: Bruvv Date: Sat, 1 Jan 2022 14:03:15 +0100 Subject: [PATCH] fixed SC2163 and SC2068 --- arpspoof/rootfs/scripts/00-global_var.sh | 13 ++++---- .../rootfs/scripts/00-global_var.sh | 13 ++++---- fireflyiii/rootfs/scripts/00-global_var.sh | 13 ++++---- .../rootfs/scripts/00-global_var.sh | 13 ++++---- joplin/rootfs/scripts/00-global_var.sh | 13 ++++---- whoogle/rootfs/scripts/00-global_var.sh | 33 +++++++++++++++++++ 6 files changed, 68 insertions(+), 30 deletions(-) create mode 100644 whoogle/rootfs/scripts/00-global_var.sh diff --git a/arpspoof/rootfs/scripts/00-global_var.sh b/arpspoof/rootfs/scripts/00-global_var.sh index e88ad363a..439bad67a 100644 --- a/arpspoof/rootfs/scripts/00-global_var.sh +++ b/arpspoof/rootfs/scripts/00-global_var.sh @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bashio - +# shellcheck shell=bash ################################### # Export all addon options as env # ################################### @@ -10,13 +10,13 @@ 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 +for KEYS in "${arr[@]}"; do # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) + VALUE=$(jq ."$KEYS" ${JSONSOURCE}) line="${KEYS}=${VALUE//[\"\']/}" # Use locally if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi - export $line + export line # Export the variable to run scripts line="${KEYS}=${VALUE//[\"\']/} &>/dev/null" sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* @@ -26,8 +26,9 @@ done # Set timezone # ################ if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; 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 + ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" >/etc/timezone fi fi + diff --git a/enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh b/enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh index e88ad363a..439bad67a 100644 --- a/enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh +++ b/enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bashio - +# shellcheck shell=bash ################################### # Export all addon options as env # ################################### @@ -10,13 +10,13 @@ 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 +for KEYS in "${arr[@]}"; do # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) + VALUE=$(jq ."$KEYS" ${JSONSOURCE}) line="${KEYS}=${VALUE//[\"\']/}" # Use locally if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi - export $line + export line # Export the variable to run scripts line="${KEYS}=${VALUE//[\"\']/} &>/dev/null" sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* @@ -26,8 +26,9 @@ done # Set timezone # ################ if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; 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 + ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" >/etc/timezone fi fi + diff --git a/fireflyiii/rootfs/scripts/00-global_var.sh b/fireflyiii/rootfs/scripts/00-global_var.sh index e88ad363a..439bad67a 100644 --- a/fireflyiii/rootfs/scripts/00-global_var.sh +++ b/fireflyiii/rootfs/scripts/00-global_var.sh @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bashio - +# shellcheck shell=bash ################################### # Export all addon options as env # ################################### @@ -10,13 +10,13 @@ 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 +for KEYS in "${arr[@]}"; do # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) + VALUE=$(jq ."$KEYS" ${JSONSOURCE}) line="${KEYS}=${VALUE//[\"\']/}" # Use locally if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi - export $line + export line # Export the variable to run scripts line="${KEYS}=${VALUE//[\"\']/} &>/dev/null" sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* @@ -26,8 +26,9 @@ done # Set timezone # ################ if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; 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 + ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" >/etc/timezone fi fi + diff --git a/fireflyiii_data_importer/rootfs/scripts/00-global_var.sh b/fireflyiii_data_importer/rootfs/scripts/00-global_var.sh index e88ad363a..439bad67a 100644 --- a/fireflyiii_data_importer/rootfs/scripts/00-global_var.sh +++ b/fireflyiii_data_importer/rootfs/scripts/00-global_var.sh @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bashio - +# shellcheck shell=bash ################################### # Export all addon options as env # ################################### @@ -10,13 +10,13 @@ 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 +for KEYS in "${arr[@]}"; do # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) + VALUE=$(jq ."$KEYS" ${JSONSOURCE}) line="${KEYS}=${VALUE//[\"\']/}" # Use locally if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi - export $line + export line # Export the variable to run scripts line="${KEYS}=${VALUE//[\"\']/} &>/dev/null" sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* @@ -26,8 +26,9 @@ done # Set timezone # ################ if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; 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 + ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" >/etc/timezone fi fi + diff --git a/joplin/rootfs/scripts/00-global_var.sh b/joplin/rootfs/scripts/00-global_var.sh index e88ad363a..439bad67a 100644 --- a/joplin/rootfs/scripts/00-global_var.sh +++ b/joplin/rootfs/scripts/00-global_var.sh @@ -1,5 +1,5 @@ #!/usr/bin/with-contenv bashio - +# shellcheck shell=bash ################################### # Export all addon options as env # ################################### @@ -10,13 +10,13 @@ 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 +for KEYS in "${arr[@]}"; do # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) + VALUE=$(jq ."$KEYS" ${JSONSOURCE}) line="${KEYS}=${VALUE//[\"\']/}" # Use locally if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi - export $line + export line # Export the variable to run scripts line="${KEYS}=${VALUE//[\"\']/} &>/dev/null" sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* @@ -26,8 +26,9 @@ done # Set timezone # ################ if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; 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 + ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" >/etc/timezone fi fi + diff --git a/whoogle/rootfs/scripts/00-global_var.sh b/whoogle/rootfs/scripts/00-global_var.sh new file mode 100644 index 000000000..dded572b1 --- /dev/null +++ b/whoogle/rootfs/scripts/00-global_var.sh @@ -0,0 +1,33 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=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//[\"\']/}" + # Use locally + if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi + export line + # Export the variable to run scripts + line="${KEYS}=${VALUE//[\"\']/} &>/dev/null" + 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