summaryrefslogtreecommitdiff
path: root/adduser.local
blob: 129ae5b332a351261be151edfcd6ab9796b9c419 (plain)
  1. #!/bin/sh
  2. set -e
  3. NEWUSERNAME=$1
  4. NEWUID=$2
  5. NEWGID=$3
  6. NEWHOMEDIR=$4
  7. . /etc/adduser.conf
  8. # Ignore non-human accounts silently
  9. [ "$NEWUID" -ge "$FIRST_UID" -a "$NEWUID" -le "$LAST_UID" ] || exit 0
  10. [ -f /etc/local/users.conf ] && . /etc/local/users.conf
  11. # Samba password
  12. #FIXME: Check if enabled in samba.conf (or included files!)
  13. if [ -x /usr/local/sbin/smbadduser -a -f /etc/samba/smbpasswd -a -x /bin/csh ]; then
  14. /usr/local/sbin/smbadduser $NEWUSERNAME:$NEWUSERNAME
  15. fi
  16. # Mail forwarding
  17. if [ -x /usr/local/sbin/userforward ]; then
  18. echo -n "Forward mail to an external account (y/N)? "
  19. read mailforward
  20. case $mailforward in
  21. y|Y)
  22. echo -n "Enter external email address: "
  23. read mail_address
  24. case $mail_address in
  25. ?*@?*.*)
  26. /usr/local/sbin/userforward $NEWUSERNAME $mailforward
  27. ;;
  28. ?*)
  29. echo "That wasn't a proper email address - skipping..."
  30. ;;
  31. esac
  32. ;;
  33. esac
  34. fi
  35. # Mailing lists
  36. #FIXME: Be more generic - support other mailinglists than mailman!
  37. listdir="/var/lib/mailman/lists"
  38. lists=""
  39. [ -d $listdir ] && \
  40. lists=`find $listdir -type d -mindepth 1 -maxdepth 1 -exec basename '{}' \;`
  41. for list in $lists; do
  42. if [ -d $listdir/$list -a -x /usr/sbin/add_members ]; then
  43. echo -n "Subscribe to mailinglist $list (y/N)? "
  44. read subscribe
  45. case $subscribe in
  46. y|Y)
  47. /bin/echo $NEWUSERNAME@`/bin/dnsdomainname` \
  48. | /usr/sbin/add_members -n - users
  49. ;;
  50. esac
  51. fi
  52. done
  53. if [ -f /etc/local/users.conf ]; then
  54. . /etc/local/users.conf
  55. if [ -n "$USERS_GROUPNAME" ]; then
  56. addgroup $NEWUSERNAME $USERS_GROUPNAME
  57. fi
  58. if [ -n "$REALUSERS_GROUPNAME" ]; then
  59. echo "This system has both dummy and real users:"
  60. echo " Dummy users have read access to specific files."
  61. echo " Real users have read/write access to personal files."
  62. echo -n "Is this a dummy user (Y/n)? "
  63. read realuser
  64. case $realuser in
  65. y|Y|"")
  66. ;;
  67. *)
  68. addgroup $NEWUSERNAME $REALUSERS_GROUPNAME
  69. ;;
  70. esac
  71. fi
  72. fi
  73. if [ -x /usr/local/sbin/user-init ]; then
  74. /usr/local/sbin/user-init $NEWUSERNAME
  75. fi