From 0483cf07c2fa7f3c522f08b6a08909963511f735 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Tue, 20 Dec 2005 02:01:35 +0000 Subject: Improved mailinglist handling. --- deluser.local | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'deluser.local') diff --git a/deluser.local b/deluser.local index 1be8964..d63cc97 100755 --- a/deluser.local +++ b/deluser.local @@ -3,7 +3,7 @@ # /usr/local/sbin/deluser.local # Copyright 2001-2002 Jonas Smedegaard # -# $Id: deluser.local,v 1.15 2004-12-07 15:53:10 jonas Exp $ +# $Id: deluser.local,v 1.16 2005-12-20 02:01:35 jonas Exp $ # # Common deluser additions for Spiff and Xenux networks # @@ -15,6 +15,12 @@ OLDUID=$2 OLDGID=$3 OLDHOMEDIR=$4 +function fullname() { getent passwd $NEWUSERNAME | awk -F: '{print $5}' | awk -F, '{print $1}'; } +function maildomain() { if [ -r /etc/mailname ]; then head -n 1 /etc/mailname; fi; } + +function listlists() { if [ -x /usr/sbin/list_lists ]; then /usr/sbin/list_lists -ab; fi; } +function delfromlist() { /bin/echo "$1" | /usr/sbin/remove_members -f - "$2"; } + . /etc/adduser.conf #. /etc/deluser.conf @@ -36,18 +42,17 @@ fi #TODO: Netatalk password # Mailinglists -#FIXME: Be more generic - support other mailinglists than mailman! -echo "Remove from all mailinglists..." -listdir="/var/lib/mailman/lists" -lists="" -[ -d $listdir ] && \ - lists=`find $listdir -type d -mindepth 1 -maxdepth 1 -exec basename '{}' \;` -for list in $lists; do - if [ -d $listdir/$list -a -x /usr/sbin/remove_members ]; then - /bin/echo $OLDUSERNAME@`hostname -d` \ - | /usr/sbin/remove_members -f - $list + +maildomain="`maildomain`" +if [ -n "$maildomain" ]; then + lists="`listlists`" + if [ -n "$lists" ]; then + echo -n "Unsubscribing $NEWUSERNAME@$maildomain from mailinglists..." fi -done + for list in $lists; do + delfromlist "$NEWUSERNAME@$maildomain" "$list" + done +fi # Check for dummy shared files if enabled in /etc/local/users.conf if [ -n "$DUMMYSHAREDDIR" ]; then -- cgit v1.2.3