Usually a Postfix installation under a Debian or Ubuntu Linux is followed by an interactive question like this:
apt-get install postfix
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
No comments yet.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Office PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder