summaryrefslogtreecommitdiff
path: root/deluser.local
blob: 5e5f078c3c451f65cbb3f5e7880e41fb1aaaf0e6 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/deluser.local
  4. # Copyright 2001-2002 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: deluser.local,v 1.14 2004-05-13 13:05:56 jonas Exp $
  7. #
  8. # Common deluser additions for Spiff and Xenux networks
  9. #
  10. # TODO: Allow local overriding of using /etc/mailname
  11. #
  12. OLDUSERNAME=$1
  13. OLDUID=$2
  14. OLDGID=$3
  15. OLDHOMEDIR=$4
  16. . /etc/adduser.conf
  17. #. /etc/deluser.conf
  18. # Workaround: default deluser.conf is not sh-compatible (like adduser.conf)
  19. REMOVE_HOME=`grep REMOVE_HOME /etc/deluser.conf | awk -F= '{print $2}' | head -1 | sed 's/^ //g'`
  20. # Ignore non-human accounts silently
  21. [ "$OLDUID" -ge "$FIRST_UID" -a "$OLDUID" -le "$LAST_UID" ] || exit 0
  22. [ -f /etc/local/users.conf ] && . /etc/local/users.conf
  23. # Samba password
  24. if [ -x /usr/bin/pdbedit ]; then
  25. /usr/bin/pdbedit -x -u "$NEWUSERNAME"
  26. elif [ -e /etc/samba/smbpasswd -a -x /usr/bin/smbpasswd ]; then
  27. /usr/bin/smbpasswd -x $OLDUSERNAME || true
  28. fi
  29. #TODO: Netatalk password
  30. # Mailinglists
  31. #FIXME: Be more generic - support other mailinglists than mailman!
  32. echo "Remove from all mailinglists..."
  33. listdir="/var/lib/mailman/lists"
  34. lists=""
  35. [ -d $listdir ] && \
  36. lists=`find $listdir -type d -mindepth 1 -maxdepth 1 -exec basename '{}' \;`
  37. for list in $lists; do
  38. if [ -d $listdir/$list -a -x /usr/sbin/remove_members ]; then
  39. /bin/echo $OLDUSERNAME@`hostname -d` \
  40. | /usr/sbin/remove_members -f - $list
  41. fi
  42. done
  43. # Check for dummy shared files if enabled in /etc/local/users.conf
  44. if [ -n "$DUMMYSHAREDDIR" ]; then
  45. if [ -d $DUMMYSHAREDDIR/$OLDUSERNAME -a -n "$OLDUSERNAME" ]; then
  46. echo -n "It seems this was a dummy user. Remove shared files (y/N)? "
  47. read remove_files
  48. case $remove_files in
  49. y|Y)
  50. rm -rf $DUMMYSHAREDDIR/$OLDUSERNAME
  51. ;;
  52. esac
  53. fi
  54. fi
  55. # Workaround: It seems deluser avoids symlinks when told to remove homedir
  56. if [ "$REMOVE_HOME" = "1" -a -d $OLDHOMEDIR ]; then
  57. echo "Removing $OLDHOMEDIR..."
  58. rm -rf $OLDHOMEDIR
  59. fi