Postfix Makefiles

Postfix uses a series of map files to do its work; we most commonly use virtual alias maps for email addresses. When the file is updated, you need to rebuild the .db so the changes can take effect. Postfix uses these .db files because they're more efficient (faster) than unprocessed text files.

Sidenote: we happen to use hash maps, which these directions apply to. There are other kinds of maps available, but we're not concerned with them.

The use of a Makefile helps ensure you can work more efficiently and don't have to think as much, which is always a good thing. After updating a plaintext map file, you save the changes then run make inside /etc/postfix. It will ensure that any relevant .db files are rebuilt, and tells postfix to reload its configuration immediately to pick up the changes.

This Makefile is Redhat-specific in that it uses /sbin/service to reload postfix. You can also use invoke-rc.d on Debian, raw initscripts, etc.

POSTMAP = postmap
MAPS = virtual.db relay-domains.db transport.db
RELOAD = /sbin/service postfix reload

all: $(MAPS)

$(MAPS): %.db: %
        $(POSTMAP) $*

# just in case the pre-map file doesn't exist yet
        touch $@

.PHONY: all