#!/bin/sh -e # Source functions library . /etc/chroot.d/functions [ -n "$verbose" ] && err_null= || err_null='2>/dev/null' eval /usr/sbin/postconf >/dev/null $err_null || exit cd /var/spool/postfix force_alias= force_map= if [ -n "$force" ]; then force_alias=1 force_map=1 # Purge all configs from chroot rm -f etc/* fi copy_resolv_conf suffix_hash=db suffix_cdb=cdb # alias_database if [ -z "$force_alias" ]; then for type in hash cdb; do update_alias= eval suffix=\$suffix_$type for src in `/usr/sbin/postconf -h alias_database | tr -s ', ' '\n' | sort -u | sed -ne 's,^'$type':\(/.*\),\1,p'`; do [ -f "$src" ] || continue dst="$src.$suffix" [ -f "$dst" ] && [ "$dst" -nt "$src" ] && continue || update_alias=1 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 # other maps for type in hash cdb; do eval suffix=\$suffix_$type for src in `/usr/sbin/postconf | grep -v '^alias_' | tr -s ', ' '\n' | sort -u | sed -ne 's,^'$type':\(/.*\),\1,p'`; do [ -f "$src" ] || continue update_map= if [ -z "$force_map" ]; then dst="$src.$suffix" [ -f "$dst" ] && [ "$dst" -nt "$src" ] && continue || update_map=1 fi if [ -n "$force_map" -o -n "$update_map" ]; then postmap $verbose "$type:$src" || Fatal "failed to update $src database" fi done done