I have the file ~/nginx_app containing this conf template:
server {
root /var/www/html/${domain}/;
server_name ${domain} www.${domain};
}
I also have this script:
#!/bin/bash
domain="$1" && test -z ${domain} && return
cat ~/myAddons/nginx_app > /etc/sites-available/${domain}.conf
As you can see, I desire to redirect the content of nginx_app into ${domain}.conf, which the script creates based on the template.
Now, need the variables inside the template to be expanded, when their cat redirection takes place. How would you promise that expansion does indeed take place?
I was thinking of here-string but I know it prints a string:
cat > "etc/nginx/sites-available/${domain}.conf" <<< "source ~/myAddons/nginx_app"
And also of this
cat ~/myAddons/nginx_app > etc/nginx/sites-available/${domain}.conf
Update
After running the script, the end state should /etc/sites-available/example.com.conf:
server {
root /var/www/html/example.com/;
server_name example.com www.example.com;
}