Created
November 15, 2013 08:40
-
-
Save fumiyas/7481098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Postfix: Makefile to update *.db files | |
POSTCONF= /usr/sbin/postconf | |
POSTMAP= /usr/sbin/postmap | |
default: postmap | |
postmap: Makefile.postmap | |
@echo 'Updating database files ...' | |
$(MAKE) -f Makefile.postmap | |
Makefile.postmap: main.cf | |
@echo 'Updating $@ ...' | |
@set -e; \ | |
rm -f $@.$$$$.tmp; \ | |
echo 'POSTMAP=$(POSTMAP)' >>$@.$$$$.tmp; \ | |
echo 'postmap::' >>$@.$$$$.tmp; \ | |
config_directory="$(PWD)"; \ | |
{ $(POSTCONF) -c $(PWD) || kill $$$$; } \ | |
|tr ' ' '\n' \ | |
|sed -n \ | |
-e 's/,$$//' \ | |
-e 's#^hash:\$$config_directory/##p' \ | |
-e 's#^hash:'"$$config_directory/##p" \ | |
|sort -u \ | |
|while read mapfile; do \ | |
echo "postmap:: $$mapfile.db" >>$@.$$$$.tmp; \ | |
echo "$$mapfile.db: $$mapfile" >>$@.$$$$.tmp; \ | |
echo " \$$(POSTMAP) $$<" >>$@.$$$$.tmp; \ | |
done; \ | |
mv $@.$$$$.tmp $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment