Github bot : script beautyshied

This commit is contained in:
github-actions
2024-01-07 00:13:46 +00:00
parent cea02260da
commit 3dd2d28354
2 changed files with 52 additions and 52 deletions

View File

@@ -18,52 +18,52 @@ for KEYS in "${arr[@]}"; do
VALUE=$(jq ."$KEYS" "${JSONSOURCE}") VALUE=$(jq ."$KEYS" "${JSONSOURCE}")
# Check if the value is an array # Check if the value is an array
if [[ "$VALUE" == \[* ]]; then if [[ "$VALUE" == \[* ]]; then
bashio::log.warning "$VALUE is an array, skipping" bashio::log.warning "$VALUE is an array, skipping"
else else
# Continue for single values # Continue for single values
VALUE="${VALUE//[\"\']/}" VALUE="${VALUE//[\"\']/}"
line="${KEYS}='${VALUE}'" line="${KEYS}='${VALUE}'"
# Check if secret # Check if secret
if [[ "${line}" == *'!secret '* ]]; then if [[ "${line}" == *'!secret '* ]]; then
echo "secret detected" echo "secret detected"
secret=${line#*secret } secret=${line#*secret }
# Check if single match # Check if single match
secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml) 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" [[ "$secretnum" == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file"
# Get text # Get text
secret=$(sed -n "/$secret:/p" /config/secrets.yaml) secret=$(sed -n "/$secret:/p" /config/secrets.yaml)
secret=${secret#*: } secret=${secret#*: }
line="${line%%=*}='$secret'" line="${line%%=*}='$secret'"
VALUE="$secret" VALUE="$secret"
fi fi
# text # text
if bashio::config.false "verbose" || [[ "${KEYS}" == *"PASS"* ]]; then if bashio::config.false "verbose" || [[ "${KEYS}" == *"PASS"* ]]; then
bashio::log.blue "${KEYS}=******" bashio::log.blue "${KEYS}=******"
else else
bashio::log.blue "$line" bashio::log.blue "$line"
fi fi
###################################### ######################################
# Export the variable to run scripts # # Export the variable to run scripts #
###################################### ######################################
export "$line" export "$line"
# export to python # export to python
if command -v "python3" &>/dev/null; then if command -v "python3" &>/dev/null; then
[ ! -f /env.py ] && echo "import os" > /env.py [ ! -f /env.py ] && echo "import os" > /env.py
echo "os.environ['${KEYS}'] = '${VALUE//[\"\']/}'" >> /env.py echo "os.environ['${KEYS}'] = '${VALUE//[\"\']/}'" >> /env.py
python3 /env.py python3 /env.py
fi fi
# set .env # set .env
echo "$line" >> /.env || true echo "$line" >> /.env || true
# set /etc/environment # set /etc/environment
mkdir -p /etc mkdir -p /etc
echo "$line" >> /etc/environment echo "$line" >> /etc/environment
# For non s6 # 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/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 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 # For s6
if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" > /var/run/s6/container_environment/"${KEYS}"; fi if [ -d /var/run/s6/container_environment ]; then printf "%s" "${VALUE}" > /var/run/s6/container_environment/"${KEYS}"; fi
echo "export ${KEYS}='${VALUE}'" >> ~/.bashrc echo "export ${KEYS}='${VALUE}'" >> ~/.bashrc
fi fi
done done

View File

@@ -18,15 +18,15 @@ done
# If custom config # If custom config
if [ "$CONFIGLOCATION" != "/config" ]; then if [ "$CONFIGLOCATION" != "/config" ]; then
# Create new config folder if needed # Create new config folder if needed
for file in $(grep -srl "PUID" /etc/cont-init.d /etc/s6-overlay/s6-rc.d); do for file in $(grep -srl "PUID" /etc/cont-init.d /etc/s6-overlay/s6-rc.d); do
sed -i "1a mkdir -p $CONFIGLOCATION" "$file" sed -i "1a mkdir -p $CONFIGLOCATION" "$file"
done done
# Correct config location # Correct config location
for file in $(grep -Esril "/config[ '\"/]|/config\$" /etc /defaults); do for file in $(grep -Esril "/config[ '\"/]|/config\$" /etc /defaults); do
sed -Ei "s=(/config)+(/| |$|\"|\')=$CONFIGLOCATION\2=g" "$file" sed -Ei "s=(/config)+(/| |$|\"|\')=$CONFIGLOCATION\2=g" "$file"
done done
fi fi