From 3dd2d283544ad94688b906771ab0a8a4ed842aa5 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 7 Jan 2024 00:13:46 +0000 Subject: [PATCH] Github bot : script beautyshied --- .templates/00-global_var.sh | 88 ++++++++++++++++++------------------- .templates/ha_lsio.sh | 16 +++---- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/.templates/00-global_var.sh b/.templates/00-global_var.sh index 2b58c3d68..cb341a4d3 100755 --- a/.templates/00-global_var.sh +++ b/.templates/00-global_var.sh @@ -18,52 +18,52 @@ for KEYS in "${arr[@]}"; do VALUE=$(jq ."$KEYS" "${JSONSOURCE}") # Check if the value is an array if [[ "$VALUE" == \[* ]]; then - bashio::log.warning "$VALUE is an array, skipping" + bashio::log.warning "$VALUE is an array, skipping" else - # Continue for single values - VALUE="${VALUE//[\"\']/}" - line="${KEYS}='${VALUE}'" - # Check if secret - if [[ "${line}" == *'!secret '* ]]; then - echo "secret detected" - secret=${line#*secret } - # Check if single match - secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml) - [[ "$secretnum" == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file" - # Get text - secret=$(sed -n "/$secret:/p" /config/secrets.yaml) - secret=${secret#*: } - line="${line%%=*}='$secret'" - VALUE="$secret" - fi - # text - if bashio::config.false "verbose" || [[ "${KEYS}" == *"PASS"* ]]; then - bashio::log.blue "${KEYS}=******" - else - bashio::log.blue "$line" - fi + # Continue for single values + VALUE="${VALUE//[\"\']/}" + line="${KEYS}='${VALUE}'" + # Check if secret + if [[ "${line}" == *'!secret '* ]]; then + echo "secret detected" + secret=${line#*secret } + # Check if single match + secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml) + [[ "$secretnum" == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file" + # Get text + secret=$(sed -n "/$secret:/p" /config/secrets.yaml) + secret=${secret#*: } + line="${line%%=*}='$secret'" + VALUE="$secret" + fi + # text + if bashio::config.false "verbose" || [[ "${KEYS}" == *"PASS"* ]]; then + bashio::log.blue "${KEYS}=******" + else + bashio::log.blue "$line" + fi - ###################################### - # Export the variable to run scripts # - ###################################### - export "$line" - # export to python - if command -v "python3" &>/dev/null; then - [ ! -f /env.py ] && echo "import os" > /env.py - echo "os.environ['${KEYS}'] = '${VALUE//[\"\']/}'" >> /env.py - python3 /env.py - fi - # set .env - echo "$line" >> /.env || true - # set /etc/environment - mkdir -p /etc - echo "$line" >> /etc/environment - # For non s6 - 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 - # For s6 - if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" > /var/run/s6/container_environment/"${KEYS}"; fi - echo "export ${KEYS}='${VALUE}'" >> ~/.bashrc + ###################################### + # Export the variable to run scripts # + ###################################### + export "$line" + # export to python + if command -v "python3" &>/dev/null; then + [ ! -f /env.py ] && echo "import os" > /env.py + echo "os.environ['${KEYS}'] = '${VALUE//[\"\']/}'" >> /env.py + python3 /env.py + fi + # set .env + echo "$line" >> /.env || true + # set /etc/environment + mkdir -p /etc + echo "$line" >> /etc/environment + # For non s6 + 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 + # For s6 + if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" > /var/run/s6/container_environment/"${KEYS}"; fi + echo "export ${KEYS}='${VALUE}'" >> ~/.bashrc fi done diff --git a/.templates/ha_lsio.sh b/.templates/ha_lsio.sh index c23b72aaa..fa21dc950 100755 --- a/.templates/ha_lsio.sh +++ b/.templates/ha_lsio.sh @@ -18,15 +18,15 @@ done # If custom config if [ "$CONFIGLOCATION" != "/config" ]; then -# Create new config folder if needed -for file in $(grep -srl "PUID" /etc/cont-init.d /etc/s6-overlay/s6-rc.d); do - sed -i "1a mkdir -p $CONFIGLOCATION" "$file" -done + # Create new config folder if needed + for file in $(grep -srl "PUID" /etc/cont-init.d /etc/s6-overlay/s6-rc.d); do + sed -i "1a mkdir -p $CONFIGLOCATION" "$file" + done -# Correct config location -for file in $(grep -Esril "/config[ '\"/]|/config\$" /etc /defaults); do - sed -Ei "s=(/config)+(/| |$|\"|\')=$CONFIGLOCATION\2=g" "$file" -done + # Correct config location + for file in $(grep -Esril "/config[ '\"/]|/config\$" /etc /defaults); do + sed -Ei "s=(/config)+(/| |$|\"|\')=$CONFIGLOCATION\2=g" "$file" + done fi