jean-cloud-services/provisioning/roles/deploy_all/files/bin/template.sh
2023-09-15 10:57:47 +02:00

13 lines
395 B
Bash
Executable File

#!/bin/bash
if [ "$1" = '-h' ] || [ "$1" = '--help' ] ; then
echo "Usage: $0 <env_file>" >&2
echo "This script read env_file variables and replace theire occurences in stdin" >&2
exit 0
fi
if [ -f "$1" ] ; then
bash -c 'set -a && . '"$1"' && envsubst "$(cat '"$1"' | grep -o ^.*= | sed "s/=//" | sed "s/^/$/")"'
else
echo "No env file found, no modifications made." >&2
cat /dev/stdin
fi