diff -uNr old/postfix.conf new/postfix.conf --- old/postfix.conf 2016-03-02 17:52:33.000000000 +0300 +++ new/postfix.conf 2019-11-09 23:32:07.173447039 +0300 @@ -5,33 +5,35 @@ [ -n "$verbose" ] && err_null= || err_null='2>/dev/null' postconf='/usr/sbin/postconf -E' -eval $postconf >/dev/null $err_null || exit -cd /var/spool/postfix - -incompatible_maps="alias_database alias_maps" -force_alias= -force_alias_maps= -force_map= -if [ -n "$force" ]; then +for pinst in /etc/postfix $($postconf -h multi_instance_directories); do + eval $postconf -c $pinst >/dev/null $err_null || continue + cd "$($postconf -c $pinst -h queue_directory)" + pwd | grep -q "^/var/spool/postfix.*" || continue + + incompatible_maps="alias_database alias_maps" + force_alias= + force_alias_maps= + force_map= + if [ -n "$force" ]; then force_alias=1 force_alias_maps=1 force_map=1 # Purge all configs from chroot rm -f etc/* -fi + fi -copy_resolv_conf + copy_resolv_conf -suffix_hash=db -suffix_cdb=cdb + suffix_hash=db + suffix_cdb=cdb -# alias_database -if [ -z "$force_alias" ]; then + # alias_database + if [ -z "$force_alias" ]; then for type in hash cdb; do update_alias= eval suffix=\$suffix_$type - for src in `$postconf -h alias_database | + for src in `$postconf -c $pinst -h alias_database | tr -s ', ' '\n' | sort -u | sed -n 's,^'$type':\(/.*\),\1,p'`; do @@ -42,16 +44,16 @@ break 2 done done -fi -if [ -n "$force_alias" -o -n "$update_alias" ]; then - /usr/bin/newaliases $verbose || - Fatal "failed to update alias database" -fi + fi + if [ -n "$force_alias" -o -n "$update_alias" ]; then + /usr/bin/newaliases -C $pinst $verbose || + Info "failed to update alias database for $pinst" + fi # alias_maps -for type in hash cdb; do + for type in hash cdb; do eval suffix=\$suffix_$type - for src in `$postconf -h alias_maps | + for src in `$postconf -c $pinst -h alias_maps | tr -s ', ' '\n' | sort -u | sed -n 's,^'$type':\(/.*\),\1,p'`; do @@ -63,22 +65,22 @@ update_alias_map=1 fi if [ -n "$force_alias_map" -o -n "$update_alias_map" ]; then - postalias $verbose "$src" || - Fatal "failed to update alias map $src database" + postalias -c $pinst $verbose "$src" || + Info "failed to update alias map $src database for $pinst" fi done -done + done # other maps -for type in hash cdb; do + for type in hash cdb; do eval suffix=\$suffix_$type - for src in `$postconf | + for src in `$postconf -c $pinst | tr -s ', ' '\n' | sort -u | sed -n 's,^'$type':\(/.*\),\1,p'`; do # Filter out incompatible maps for map in $incompatible_maps; do - test "`$postconf -h $map`" = "$type:$src" && src="" && break || : + test "`$postconf -c $pinst -h $map`" = "$type:$src" && src="" && break || : done [ -f "$src" ] || continue update_map= @@ -88,14 +90,15 @@ update_map=1 fi if [ -n "$force_map" -o -n "$update_map" ]; then - postmap $verbose "$type:$src" || - Fatal "failed to update $src database" + postmap -c $pinst $verbose "$type:$src" || + Info "failed to update $src database for $pinst" fi done -done + done -nono='no + nono='no no' -if [ "`$postconf -h smtp_use_tls smtpd_use_tls`" != "$nono" ]; then + if [ "`$postconf -c $pinst -h smtp_use_tls smtpd_use_tls`" != "$nono" ]; then : # Consider updating files specified in smtp{,d}_tls_CA{file,path} -fi + fi +done diff -uNr old/postfix.lib new/postfix.lib --- old/postfix.lib 2016-03-02 17:52:33.000000000 +0300 +++ new/postfix.lib 2019-11-09 23:24:43.272914416 +0300 @@ -5,11 +5,16 @@ # Source functions library . /etc/chroot.d/functions -cd /var/spool/postfix +postconf='/usr/sbin/postconf -E' -if [ -n "$force" ]; then +for pinst in /etc/postfix $($postconf -h multi_instance_directories); do + cd "$($postconf -c $pinst -h queue_directory)" + pwd | grep -q "^/var/spool/postfix.*" || continue + + if [ -n "$force" ]; then # Purge all libs from chroot rm -f ${chrooted_slib}/* -fi + fi -copy_resolv_lib + copy_resolv_lib +done