cat重定向文件,但扩展名可变

I have the file ~/nginx_app containing this conf template:

server {
    root /var/www/html/${domain}/;
    server_name ${domain} www.${domain};
}

我也有这个脚本:

#!/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?

我在想这里字符串,但我知道它会打印一个字符串:

cat > "etc/nginx/sites-available/${domain}.conf" <<< "source ~/myAddons/nginx_app"

还有这个

cat ~/myAddons/nginx_app > etc/nginx/sites-available/${domain}.conf

更新资料

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;
}