This commit is contained in:
Alexandre
2023-11-23 10:16:47 +01:00
committed by GitHub
parent 781201faf4
commit c9df02116b

View File

@@ -41,25 +41,18 @@ for KEYS in "${arr[@]}"; do
######################################
# Export the variable to run scripts #
######################################
# Sanitize " ' ` in current variable
VALUE="${VALUE//[\"\'\`]/}"
if [[ "$VALUE" = *" "* ]]; then
VALUE="'$VALUE'"
fi
# Export
export "${KEYS}=${VALUE}"
export "${KEYS}='${VALUE}'"
# set .env
echo "$KEYS=$VALUE" >> /.env || true
echo "$KEYS=\"$VALUE\"" >> /.env || true
# set /etc/environment
mkdir -p /etc
echo "$KEYS=$VALUE" >> /etc/environment
# For non s6
if cat /etc/services.d/*/*run* &>/dev/null; then sed -i "1a export ${KEYS}=${VALUE}" /etc/services.d/*/*run* 2>/dev/null; fi
if cat /etc/cont-init.d/*run* &>/dev/null; then sed -i "1a export ${KEYS}=${VALUE}" /etc/cont-init.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
# 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
echo "export ${KEYS}=\"${VALUE}\"" >> ~/.bashrc
done