have anybody a smarter way to prepare template files via bash script?
This is the current script:
#!/bin/bash
projectDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Project root: $projectDir"
echo "> Is this the project root directory? (y/n)"
read validProjectPath
#if [ "$isProjectDir" != "y" ] then exit 1 fi
echo "> Your OS user name (e.g. peter):"
read userName
echo "> VM IPv4 address (e.g. 192.168.178.2):"
read ipv4
# setup
echo "prepare configuration files..."
for f in $(find "$projectDir/vagrant" -name "*.template" -type f); do
toFile=${f/.template/}
cp $f $f.bak
sed "s/_CHANGE_PRODIR_/$projectDir/g" $f.bak > $f.bak1
sed "s/_CHANGE_USERNAME_/$userName/g" $f.bak1 > $f.bak2
sed "s/_CHANGE_IPV4_/$ipv4/g" $f.bak2 > $toFile
rm -f $f.bak
rm -f $f.bak1
rm -f $f.bak2
done
echo "... done!"
Thanks for reply. Jim