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 samplepostmulti -e initpostmulti -I postfix-$new -e createcd /etc/postfix-$newrm -rf main.cfwget http://www.********.com/*******/main.zipunzip main.zipmv main main.cfecho -e queue_directory = /var/spool/postfix-$new >> /etc/postfix-$new/main.cfecho -e data_directory = /var/lib/postfix-$new >> /etc/postfix-$new/main.cfecho -e multi_instance_name = postfix-$new >> /etc/postfix-$new/main.cfecho -e mydomain = $domain >> /etc/postfix-$new/main.cfecho -e myhostname = host1.$domain >> /etc/postfix-$new/main.cfecho -e smtp_bind_address = $ip >> /etc/postfix-$new/main.cfsed -i s/oldip/$ip/g /etc/postfix-$new/main.cfmv /etc/opendkim/keys/$domain/default.private /etc/opendkim/keys/$domain/defaultecho -e /ndefault._domainkey.$domain $domain:default:/etc/opendkim/keys/$domain/default >> /etc/opendkim/KeyTableecho -e /n*@$domain default._domainkey.$domain >> /etc/opendkim/SigningTablesed -i s/cyberciti.com/$domain/g /etc/postfix-$new/main.cfThere 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 containsnew1, 1.1.1.1, myweb.comnew2, 2.2.2.2, myweb2.comThe first line should run the followingpostmulti -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/SigningTablesed -i s/cyberciti.com/$myweb.com/g /etc/postfix-new1/main.cfand so on until all lines in the start file are complete
Bash script with data from another file
linux;bash
Here is what I would replace your script with:#!/bin/bashwhile read new ip domaindo  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.cfdone < start.txt... all I did was wrap a while loop around your existing code.If I can suggest one other minor change, it would be to consolidate all of your echo statements into one here document, like this:cat >> /etc/postfix-$new/main.cf << EOFqueue_directory = /var/spool/postfix-$newdata_directory = /var/lib/postfix-$new...EOFIf not for performance reasons (you may not care), but because it's easier to read.