How to write Bash script to install and configure Postfix on Debian-based distros

3.4k views Asked by At

How do I write a Bash script to install and configure Postfix (for Debian or Ubuntu).

This is how I install Postfix:

 sudo apt-get install postfix

Then I re-configure it:

sudo dpkg-reconfigure postfix

How do I make a script which automatically answers the questions of the reconfiguration with a predefined set of answers? Or is there any other way to do it?

2

There are 2 answers

1
f4m8 On BEST ANSWER

To show the package related debconf keys and values use debconf-show packagename.

For example the package "samba-common":

To get a single key and value from commandline use echo "get samba-common/encrypt_passwords" | debconf-communicate.

To set a single key and value from commandline use echo "set samba-common/encrypt_passwords false" | debconf-communicate.

This has the advantage, that your changes will survive debian package upgrades.

All other configuration should done with teh adviced postconf utility.

Source: http://feeding.cloud.geek.nz/2010/10/manipulating-debconf-settings-on.html

0
Emil Vikström On

Consider using the postconf tool instead of dpkg-reconfigure.