#!/bin/bash ALIASESDB_STAMP=/var/lib/misc/postfix.aliasesdb-stamp make_aliasesdb() { local MAP="" local ALIASESDB="$(/usr/sbin/postconf -h alias_database)" [ "$ALIASESDB" = "hash:/etc/aliases" ] && MAP="db" [ "$ALIASESDB" = "lmdb:/etc/aliases" ] && MAP="lmdb" if [ "$MAP" = "db" -o "$MAP" = "lmdb" ] then # /etc/aliases.db|lmdb may be used by other MTA, make sure nothing # has touched it since our last newaliases call [ /etc/aliases -nt /etc/aliases.$MAP ] || [ "$ALIASESDB_STAMP" -nt /etc/aliases.$MAP ] || [ "$ALIASESDB_STAMP" -ot /etc/aliases.$MAP ] || return 0 /usr/bin/newaliases touch -r /etc/aliases.$MAP "$ALIASESDB_STAMP" else /usr/bin/newaliases fi } make_aliasesdb