All pastes #357245 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-02-15 15:37 UTC
rendered paste body
#!/bin/sh
# helper script to help adding a mail alias file to system MTA

if [ $# != 3 ]; then
    echo "usage: $0 <pkg name> <number installed> <file>" 1>&2
    exit 1
fi

pkg=$1	# name of the package
num=$2	# number of packages installed
file=$3	# alias file to add

# only needed for installation
if [ $num = 1 ]; then
    # check mta
    mta="`readlink /etc/alternatives/sendmail-command 2>/dev/null | cut -d . -f 2`"
    if [ "$mta" == "postfix" ]; then
	maps=`/usr/sbin/postconf -h alias_maps`
	database=`/usr/sbin/postconf -h alias_database`

	postconf -e \
	    "alias_maps = $maps, hash:$file" \
	    "alias_database = $database, hash:$file"
    else
	date=`date`
	cat >> /etc/aliases <<EOF
# added by $pkg rpm $date
:include:$file
EOF
    fi

    newaliases
fi