Ubuntu Postfix – How to Automate the Installation of Postfix

aptautomationinstallationpostfixUbuntu

My system configuration script does an "apt-get install -y postfix". Unfortunately the script is halted when the postfix installer displays a configuration screen. Is there a method to force postfix to use the defaults during installation so that an automated script can continue to the end?

Does the postfix installer maybe check for existing configuration in /etc/postfix, and if it exists, not bother the user with the configuration screen?

Best Answer

You can use pre-seeding for this, using the debconf-set-selections command to pre-answer the questions asked by debconf before installing the package.

For example:

debconf-set-selections <<< "postfix postfix/mailname string your.hostname.com"
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
apt-get install --assume-yes postfix