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