Making Postfix config changes on the fly

This example shows how to update the aliases path so we have this standard across all machines in a datacentre, this is a quick hack method. The correct way to fix this in a production would be to use a configuration management system like chef/puppet or cfengine.

    PATH=$PATH:/opt/csw/bin:/opt/csw/sbin:/usr/local/bin:/usr/local/postfix/sbin
    export PATH
## Show the existing aliases paths
    postconf | grep '^alias'
## Make the changes to main.cf
    postconf -e alias_maps='dbm:/etc/mail/aliases'
    postconf -e alias_database='dbm:/etc/mail/aliases'
## Make new aliases database
    newaliases
## Show aliases paths just to make sure things have been updated
    postconf | grep '^alias'
## send test email to self
    uname -a | mailx -s "`uname -n`" pcanham@`uname -n`

Share