2020-04-14 20:22:34 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-05-17 02:59:05 +00:00
|
|
|
# The first parameter is a comma-delimited list of paths to files which should be substituted
|
2020-04-14 20:22:34 +00:00
|
|
|
if [[ -z $1 ]]; then
|
2020-05-17 02:59:05 +00:00
|
|
|
echo 'ERROR: No target files given.'
|
2020-04-14 20:22:34 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-05-17 02:59:05 +00:00
|
|
|
env_list='\$PRODUCTION \$API_URL \$IRB_URL \$HOME_ROUTE \$PORT0'
|
|
|
|
for i in $(echo $1 | sed "s/,/ /g")
|
|
|
|
do
|
|
|
|
# Replace strings in the given file(s) in env_list
|
|
|
|
envsubst "$env_list" < "$i" > "$i".tmp && mv "$i".tmp "$i"
|
2020-04-14 20:22:34 +00:00
|
|
|
|
2020-05-17 02:59:05 +00:00
|
|
|
# Set DEBUG=true in order to log the replaced file
|
|
|
|
if [ "$DEBUG" = true ] ; then
|
|
|
|
exec cat $i
|
|
|
|
fi
|
|
|
|
done
|
2020-04-14 20:22:34 +00:00
|
|
|
|
|
|
|
# Execute all other commands with parameters
|
|
|
|
exec "${@:2}"
|