jean-cloud-services/provisioning/roles/deploy_all/files/bin/template.sh

13 lines
395 B
Bash
Raw Normal View History

2023-04-24 10:11:09 +00:00
#!/bin/bash
2023-06-01 13:26:12 +00:00
if [ "$1" = '-h' ] || [ "$1" = '--help' ] ; then
2023-04-24 10:11:09 +00:00
echo "Usage: $0 <env_file>" >&2
echo "This script read env_file variables and replace theire occurences in stdin" >&2
2023-06-01 13:26:12 +00:00
exit 0
fi
if [ -f "$1" ] ; then
bash -c 'set -a && . '"$1"' && envsubst "$(cat '"$1"' | grep -o ^.*= | sed "s/=//" | sed "s/^/$/")"'
else
2023-09-15 08:57:47 +00:00
echo "No env file found, no modifications made." >&2
2023-06-01 13:26:12 +00:00
cat /dev/stdin
2023-04-24 10:11:09 +00:00
fi