Am 12.10.2014 um 02:59 schrieb Viktor Dukhovni:
On Sun, Oct 12, 2014 at 01:43:19AM +0200, li...@rhsoft.net wrote:
just generate your map file in a temp folder, map it there and move both
files to /etc/postfix, you can easily do that for a lot of map files and
only if the result have changed compared with the ones in /etc/postfix move
them at the end and isse a one time reload
This is brittle advice, since "temp folder" would typically be read
as "/tmp", which is often a different file-system than /etc/postfix,
and mv(1) is NOT atomic across file-systems.
It is best to use a temp-file in /etc/postfix, which is renamed
without moving across directories
agreed
my code looks like below
* fetch data with a PHP script from several db servers
* generate files in /scripts/tmp
* compare them with /etc/postfix
* create a array with changed files
* postmap /scripts/tmp/list.cf files
* cp -f /scripts/tmp/list.cf /etc/postfix/list.cf.tmp
* cp -f /scripts/tmp/list.cf.db /etc/postfix/list.cf.db.tmp
* touch /etc/postfix/list.cf.tmp && touch /etc/postfix/list.cf.db.tmp
* mv /etc/postfix/list.cf.tmp /etc/postfix/list.cf && mv
/etc/postfix/list.cf.db.tmp /etc/postfix/list.cf.db
the last 3 operations are done in a sequence followed by reload and if
none of the generated files has a difference to the running config
nothing happens, that way and with a lock-file for the cronjob it's safe
independent of how large the map files are and how long it takes to
generate them
design goal: first generate all connfigs and at the end touch
/etc/postfix to have maps depending on each other replaced at the same
time in case one db-source answers slow