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