Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rc.d/postfix:postfix_precmd()

0 views
Skip to first unread message

Edgar Fuß

unread,
Jul 27, 2015, 2:09:48 PM7/27/15
to
I think the part of postfix_precmd() that tries to re-build the alias
databases is less than helpful:

1. It doesn't deal with alias_database entries seperated by commas
2. It doesn't do variable expansion on the alias_database entries
3. It runs newaliases for every outdated or missing member instead of once.

I don't know how to properly handle (2). The only way I can think of is
through postconf -b, but that's quite ugly.
The most common case should be a leading $config_directory


_rebuild=false
_configdir=$($postconf -h config_directory)
_IFS="$IFS"; IFS=",$IFS"
for f in $($postconf -h alias_database); do
case $f in
hash:*) f="${f#hash:}" ;;
*) continue ;;
esac
case $f in
\$config_directory*) f="$_configdir${f#\$config_directory}" ;;
\${config_directory}*) f="$_configdir${f#\${config_directory\}}" ;;
\$\(config_directory\)*) f="$_configdir${f#\$(config_directory)}" ;;
esac
if [ ! -e "$f.db" ]; then
_reason="missing"
_rebuild=true;
elif [ "$f" -nt "$f.db" ]; then
_reason="out of date"
_rebuild=true;
else
_reason=""
fi
if [ -n "$_reason" ]; then
echo "${name}: rebuilding $f ($_reason $f.db)"
_rebuild=true
fi
done
IFS="$_IFS"

if $_rebuild; then
echo $($postconf -h newaliases_path)
fi

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-...@muc.de
0 new messages