#!/bin/bash

# aufruf ./roleaccount.sh domaindatei roleaccountdatei empfängeradresse/umleitungsadresse

DOMAIN=$1
ROLEACCOUNT=$2
EMPFANGER=$3

rm $ROLEACCOUNT;

cat $DOMAIN | grep -v "#" | awk '{print($1)}' | while read line
do
 DNS=`echo "$line"`;

  echo "postmaster@$DNS	$EMPFANGER">>$ROLEACCOUNT;
  echo "webmaster@$DNS	$EMPFANGER">>$ROLEACCOUNT;
  echo "abuse@$DNS	$EMPFANGER">>$ROLEACCOUNT;
  echo "hostmaster@$DNS	$EMPFANGER">>$ROLEACCOUNT;
  echo "support@$DNS	$EMPFANGER">>$ROLEACCOUNT;
done;

postmap $ROLEACCOUNT;
/etc/init.d/postfix reload;



# {
#	print("postmaster@"$1, $EMPFANGER);
#	print("webmaster@"$1, $EMPFANGER);
#	print("abuse@"$1, $EMPFANGER);
#	print("hostmaster@"$1, $EMPFANGER);
#	print("support@"$1, $EMPFANGER);
#
#}' 
