2020-10-27 20:21:10 +09:00
|
|
|
#!/bin/sh
|
|
|
|
USAGE="Usage: $0 ALIAS TARGET";
|
|
|
|
|
|
|
|
if [ -z "$2" ]
|
|
|
|
then
|
|
|
|
echo "$USAGE";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
DOMAINPART=$(echo $1 | sed -e "s/^.*\@//")
|
|
|
|
|
2020-11-01 02:19:13 +09:00
|
|
|
if ! grep -q "^$DOMAINPART" /etc/mail/domains
|
|
|
|
then
|
2020-10-27 20:21:10 +09:00
|
|
|
echo "This server is not responsible for the domain of this alias."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-11-01 02:19:13 +09:00
|
|
|
echo "$1 $2" >> /etc/mail/aliases
|
2020-10-27 20:21:10 +09:00
|
|
|
postmap /etc/mail/aliases
|
|
|
|
postfix reload
|
|
|
|
|
|
|
|
echo "Alias added."
|