summaryrefslogtreecommitdiff
path: root/deluser.local
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2005-12-20 02:01:35 +0000
committerJonas Smedegaard <dr@jones.dk>2005-12-20 02:01:35 +0000
commit0483cf07c2fa7f3c522f08b6a08909963511f735 (patch)
treeadfeddc0fd661ac4635aef48a571a8aae1dd7107 /deluser.local
parent64314b3a114ebf15a8166628205dbe4854ad8c30 (diff)
Improved mailinglist handling.
Diffstat (limited to 'deluser.local')
-rwxr-xr-xdeluser.local29
1 files changed, 17 insertions, 12 deletions
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 <dr@jones.dk>
#
-# $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