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