mailman/mailman-update_aliases_vmailmgr.sh

35 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/bash
#
# Generate vmailmgr aliases for mailman mailing lists
#
# 5/13/2004: created by Silvan Calarco for the QiLinux distribution
#
# Copyright (c) by Silvan Calarco <silvan.calarco@mamabsoft.it>
# Released under the GNU GPL version 2 license
test $UID = 0 ||
{ echo "error: $0: must be superuser" >&2
{ (exit 1); exit 1; }; }
[ -e /var/qmail/bin ] && {
for listdomain in `grep -v "^#" /etc/qmail/virtualdomains | sed -n "s|^\(.*\):.*|\1|p"`; do
listuser=`grep -v "^#" /etc/qmail/virtualdomains | sed -n "s|^$listdomain:\(.*\)|\1|p"`
getent passwd $listuser >/dev/null ||
{ echo "error: $0: user $listuser does not exist"
{ (exit 1); exit 1; }; }
# add mailman-* stuff to current domain
for i in `sed -n "s|^\(mailman.*\):.*|\1|p" /etc/aliases`; do
su $listuser -c "vaddalias $i mailman@localhost 2>&1 >/dev/null" >/dev/null
done
for currlist in `/usr/share/mailman/bin/list_lists -V $listdomain | sed -n "s|^[ ]*\(.*\) - .*|\1|p"`; do
for i in `sed -n "s|^\($currlist.*\):.*|\1|pi" /etc/aliases`; do
su $listuser -c "vaddalias $i $i@localhost 2>&1 >/dev/null" >/dev/null
done
done
done
}
exit 0