I have worked on the following script which I want to use to easily add multiple Postfix as well as a few other things.
Below is a small sample
postmulti -e init
postmulti -I postfix-$new -e create
cd /etc/postfix-$new
rm -rf main.cf
wget http://www.********.com/*******/main.zip
unzip main.zip
mv main main.cf
echo -e "queue_directory = /var/spool/postfix-$new" >> /etc/postfix-$new/main.cf
echo -e "data_directory = /var/lib/postfix-$new" >> /etc/postfix-$new/main.cf
echo -e "multi_instance_name = postfix-$new" >> /etc/postfix-$new/main.cf
echo -e "mydomain = $domain" >> /etc/postfix-$new/main.cf
echo -e "myhostname = host1.$domain" >> /etc/postfix-$new/main.cf
echo -e "smtp_bind_address = $ip" >> /etc/postfix-$new/main.cf
sed -i "s/oldip/$ip/g" /etc/postfix-$new/main.cf
mv /etc/opendkim/keys/$domain/default.private /etc/opendkim/keys/$domain/default
echo -e "/ndefault._domainkey.$domain $domain:default:/etc/opendkim/keys/$domain/default" >> /etc/opendkim/KeyTable
echo -e "/n*@$domain default._domainkey.$domain" >> /etc/opendkim/SigningTable
sed -i "s/cyberciti.com/$domain/g" /etc/postfix-$new/main.cf
There are three requirements for this script $new
$ip
$domain
I want to know how I can add them into a file line by line and then bash this script, one line = one full run of the script.
For example start
contains
new1, 1.1.1.1, myweb.com
new2, 2.2.2.2, myweb2.com
The first line should run the following
postmulti -e init
postmulti -I postfix-new1 -e create
cd /etc/postfix-new1
rm -rf main.cf
wget http://www.********.com/*******/main.zip
unzip main.zip
mv main main.cf
echo -e "queue_directory = /var/spool/postfix-new1" >> /etc/postfix-new1/main.cf
echo -e "data_directory = /var/lib/postfix-new1" >> /etc/postfix-new1/main.cf
echo -e "multi_instance_name = postfix-new1" >> /etc/postfix-new1/main.cf
echo -e "mydomain = myweb.com" >> /etc/postfix-new1/main.cf
echo -e "myhostname = host1.myweb.com" >> /etc/postfix-new1/main.cf
echo -e "smtp_bind_address = 1.1.1.1" >> /etc/postfix-new1/main.cf
sed -i "s/oldip/1.1.1.1/g" /etc/postfix-new1/main.cf
mv /etc/opendkim/keys/myweb.com/default.private /etc/opendkim/keys/myweb.com/default
echo -e "/ndefault._domainkey.myweb.com myweb.com:default:/etc/opendkim/keys/myweb.com/default" >> /etc/opendkim/KeyTable
echo -e "/n*@myweb.com default._domainkey.myweb.com" >> /etc/opendkim/SigningTable
sed -i "s/cyberciti.com/$myweb.com/g" /etc/postfix-new1/main.cf
and so on until all lines in the start
file are complete