summaryrefslogtreecommitdiff
path: root/adduser.local
blob: b1ba004ec2cbbac1ea9f0c5f48a085ae36f2ec00 (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.16 2004-05-13 13:05:56 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/pdbedit ]; then
  26. /usr/bin/pdbedit -a -u "$NEWUSERNAME"
  27. elif [ -x /usr/bin/smbpasswd -a -f /etc/samba/smbpasswd ]; then
  28. /usr/bin/smbpasswd -a $NEWUSERNAME
  29. fi
  30. # Mail forwarding
  31. if [ -x /usr/local/sbin/userforward ]; then
  32. echo -n "Forward mail to an external account (y/N)? "
  33. read mailforward
  34. case $mailforward in
  35. y|Y)
  36. echo -n "Enter external email address: "
  37. read mail_address
  38. case $mail_address in
  39. ?*@?*.*)
  40. /usr/local/sbin/userforward $NEWUSERNAME $mail_address
  41. ;;
  42. ?*)
  43. echo "That wasn't a proper email address - skipping..."
  44. ;;
  45. esac
  46. ;;
  47. esac
  48. fi
  49. # Mailing lists
  50. #FIXME: Be more generic - support other mailinglists than mailman!
  51. listdir="/var/lib/mailman/lists"
  52. lists=""
  53. [ -d $listdir ] && \
  54. lists=`find $listdir -type d -mindepth 1 -maxdepth 1 -exec basename '{}' \;`
  55. for list in $lists; do
  56. if [ -d $listdir/$list -a -x /usr/sbin/add_members ]; then
  57. echo -n "Subscribe to mailinglist $list (y/N)? "
  58. read subscribe
  59. case $subscribe in
  60. y|Y)
  61. /bin/echo $NEWUSERNAME@`hostname -d` \
  62. | /usr/sbin/add_members -w y -a y -r - $list
  63. ;;
  64. esac
  65. fi
  66. done
  67. if [ -f /etc/local/users.conf ]; then
  68. . /etc/local/users.conf
  69. if [ -n "$USERS_GROUPNAME" ]; then
  70. addgroup $NEWUSERNAME $USERS_GROUPNAME
  71. fi
  72. if [ -n "$REALUSERS_GROUPNAME" ]; then
  73. echo "This system has both dummy and real users:"
  74. echo " Dummy users have read access to specific files."
  75. echo " Real users have read/write access to personal files."
  76. echo -n "Is this a dummy user (Y/n)? "
  77. read realuser
  78. case $realuser in
  79. y|Y|"")
  80. ;;
  81. *)
  82. addgroup $NEWUSERNAME $REALUSERS_GROUPNAME
  83. ;;
  84. esac
  85. fi
  86. fi
  87. #if [ -n "$REALUSERS_GROUPNAME" ]; then
  88. cat <<+
  89. Is this a remote or local user (with need for physical
  90. access to devices like CD-ROM, soundcard and modem needed)?
  91. +
  92. echo -n "Grant this user access to local utilities (y/N)?"
  93. read localuser
  94. case $localuser in
  95. y|Y)
  96. for group in floppy dialout cdrom audio video games; do
  97. addgroup $NEWUSERNAME $group
  98. done
  99. ;;
  100. *)
  101. ;;
  102. esac
  103. #fi
  104. if [ -x /usr/local/sbin/user-init ]; then
  105. /usr/local/sbin/user-init $NEWUSERNAME
  106. fi