Header RSS Feed
 
If you only want to see the articles of a certain category, please click on the desired category below:
ALL Android Backup BSD Database Hacks Hardware Internet Linux Mail MySQL Monitoring Network Personal PHP Proxy Shell Solaris Unix Virtualization VMware Windows Wyse

Automate Postfix installation in Debian and Ubuntu with debconf
Monday - Jul 21st 2014 - by - (0 comments)

Usually a Postfix installation under a Debian or Ubuntu Linux is followed by an interactive question like this:

apt-get install postfix

 Postfix Installation

Nowadays in the age of LXC, this can be annoying, if the LXC template contains the installation of the postfix package.

But this can be automated through the debconf command. I added the following lines into the "configure_debian" section in Debian Wheezy's /usr/share/lxc/templates/lxc-debian template and into the "configure_ubuntu" section in Ubuntu 14.04's /usr/share/lxc/templates/lxc-ubuntu template:

echo "postfix postfix/main_mailer_type select smarthost" | chroot $rootfs debconf-set-selections
echo "postfix postfix/mailname string $hostname.localdomain" | chroot $rootfs debconf-set-selections
echo "postfix postfix/relayhost string smtp.localdomain" | chroot $rootfs debconf-set-selections

This "pre-answers" the questions coming up during the Postfix installation and the postfix installation runs through without asking anything:

apt-get install postfix
[...]
Setting up postfix (2.11.0-1) ...
Creating /etc/postfix/dynamicmaps.cf
Adding tcp map entry to /etc/postfix/dynamicmaps.cf
Adding sqlite map entry to /etc/postfix/dynamicmaps.cf
setting myhostname: myhostname
setting alias maps
setting alias database
changing /etc/mailname to myhostname.localdomain
setting myorigin
setting destinations: localhost.localdomain, localhost
setting relayhost: smtp.localdomain
setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
setting mailbox_size_limit: 0
setting recipient_delimiter: +
setting inet_interfaces: all

By the way, the settings set by "debconf-set-selections" can be verified or manually edited in /var/cache/debconf/config.dat:

cat /var/cache/debconf/config.dat | grep -B 4 seen
[...]
Name: postfix/mailname
Template: postfix/mailname
Value: myhostname.localdomain
Owners: postfix
Flags: seen
--
Name: postfix/main_mailer_type
Template: postfix/main_mailer_type
Value: smarthost
Owners: postfix
Flags: seen
--
Name: postfix/relayhost
Template: postfix/relayhost
Value: smtp.localdomain
Owners: postfix
Flags: seen


 

Add a comment

Show form to leave a comment

Comments (newest first):

No comments yet.

Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

6938 Days
until Death of Computers
Why?