blob: 1be8964534c91671daef1b748db104f04f09132c (
plain)
- #!/bin/sh
- #
- # /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 $
- #
- # Common deluser additions for Spiff and Xenux networks
- #
- # TODO: Allow local overriding of using /etc/mailname
- #
- OLDUSERNAME=$1
- OLDUID=$2
- OLDGID=$3
- OLDHOMEDIR=$4
- . /etc/adduser.conf
- #. /etc/deluser.conf
- # Workaround: default deluser.conf is not sh-compatible (like adduser.conf)
- REMOVE_HOME=`grep REMOVE_HOME /etc/deluser.conf | awk -F= '{print $2}' | head -1 | sed 's/^ //g'`
- # Ignore non-human accounts silently
- [ "$OLDUID" -ge "$FIRST_UID" -a "$OLDUID" -le "$LAST_UID" ] || exit 0
- [ -f /etc/local/users.conf ] && . /etc/local/users.conf
- # Samba password
- if [ -x /usr/bin/pdbedit ]; then
- /usr/bin/pdbedit -x -u "$OLDUSERNAME"
- elif [ -e /etc/samba/smbpasswd -a -x /usr/bin/smbpasswd ]; then
- /usr/bin/smbpasswd -x $OLDUSERNAME || true
- 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
- fi
- done
- # Check for dummy shared files if enabled in /etc/local/users.conf
- if [ -n "$DUMMYSHAREDDIR" ]; then
- if [ -d $DUMMYSHAREDDIR/$OLDUSERNAME -a -n "$OLDUSERNAME" ]; then
- echo -n "It seems this was a dummy user. Remove shared files (y/N)? "
- read remove_files
- case $remove_files in
- y|Y)
- rm -rf $DUMMYSHAREDDIR/$OLDUSERNAME
- ;;
- esac
- fi
- fi
- # Workaround: It seems deluser avoids symlinks when told to remove homedir
- if [ "$REMOVE_HOME" = "1" -a -d $OLDHOMEDIR ]; then
- echo "Removing $OLDHOMEDIR..."
- rm -rf $OLDHOMEDIR
- fi
|