summaryrefslogtreecommitdiff
path: root/adduser.local
blob: 3979f7e9db8021b1bfc829b7848cedb06d7e453c (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/adduser.local
  4. # Copyright 2001-2002 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: adduser.local,v 1.9 2002-05-13 11:08:37 jonas Exp $
  7. #
  8. # Common adduser additions for Spiff and Xenux networks
  9. #
  10. set -e
  11. NEWUSERNAME=$1
  12. NEWUID=$2
  13. NEWGID=$3
  14. NEWHOMEDIR=$4
  15. . /etc/adduser.conf
  16. # Ignore non-human accounts silently
  17. [ "$NEWUID" -ge "$FIRST_UID" -a "$NEWUID" -le "$LAST_UID" ] || exit 0
  18. [ -f /etc/local/users.conf ] && . /etc/local/users.conf
  19. # Samba password
  20. #FIXME: Check if enabled in samba.conf (or included files!)
  21. if [ -x /usr/local/sbin/smbadduser -a -f /etc/samba/smbpasswd -a -x /bin/csh ]; then
  22. /usr/local/sbin/smbadduser $NEWUSERNAME:$NEWUSERNAME
  23. fi
  24. # Mail forwarding
  25. if [ -x /usr/local/sbin/userforward ]; then
  26. echo -n "Forward mail to an external account (y/N)? "
  27. read mailforward
  28. case $mailforward in
  29. y|Y)
  30. echo -n "Enter external email address: "
  31. read mail_address
  32. case $mail_address in
  33. ?*@?*.*)
  34. /usr/local/sbin/userforward $NEWUSERNAME $mail_address
  35. ;;
  36. ?*)
  37. echo "That wasn't a proper email address - skipping..."
  38. ;;
  39. esac
  40. ;;
  41. esac
  42. fi
  43. # Mailing lists
  44. #FIXME: Be more generic - support other mailinglists than mailman!
  45. listdir="/var/lib/mailman/lists"
  46. lists=""
  47. [ -d $listdir ] && \
  48. lists=`find $listdir -type d -mindepth 1 -maxdepth 1 -exec basename '{}' \;`
  49. for list in $lists; do
  50. if [ -d $listdir/$list -a -x /usr/sbin/add_members ]; then
  51. echo -n "Subscribe to mailinglist $list (y/N)? "
  52. read subscribe
  53. case $subscribe in
  54. y|Y)
  55. /bin/echo $NEWUSERNAME@`/bin/dnsdomainname` \
  56. | /usr/sbin/add_members -n - $list
  57. ;;
  58. esac
  59. fi
  60. done
  61. if [ -f /etc/local/users.conf ]; then
  62. . /etc/local/users.conf
  63. if [ -n "$USERS_GROUPNAME" ]; then
  64. addgroup $NEWUSERNAME $USERS_GROUPNAME
  65. fi
  66. if [ -n "$REALUSERS_GROUPNAME" ]; then
  67. echo "This system has both dummy and real users:"
  68. echo " Dummy users have read access to specific files."
  69. echo " Real users have read/write access to personal files."
  70. echo -n "Is this a dummy user (Y/n)? "
  71. read realuser
  72. case $realuser in
  73. y|Y|"")
  74. ;;
  75. *)
  76. addgroup $NEWUSERNAME $REALUSERS_GROUPNAME
  77. ;;
  78. esac
  79. fi
  80. fi
  81. #if [ -n "$REALUSERS_GROUPNAME" ]; then
  82. cat <<+
  83. Is this a remote or local user (with need for physical
  84. access to devices like CD-ROM, soundcard and modem needed)?
  85. +
  86. echo -n "Grant this user access to local utilities (y/N)?"
  87. read localuser
  88. case $localuser in
  89. y|Y)
  90. for group in disk dialout cdrom audio video games; do
  91. addgroup $NEWUSERNAME $group
  92. done
  93. ;;
  94. *)
  95. ;;
  96. esac
  97. #fi
  98. if [ -x /usr/local/sbin/user-init ]; then
  99. /usr/local/sbin/user-init $NEWUSERNAME
  100. fi