#!/bin/sh # # /usr/local/sbin/adduser.local # Copyright 2001-2002 Jonas Smedegaard # # $Id: adduser.local,v 1.17 2004-09-25 21:00:06 jonas Exp $ # # Common adduser additions for Spiff and Xenux networks # # TODO: Allow local overriding of using /etc/mailname # TODO: Only ask additional questions if real user # TODO: handle samba passwords in /var/lib/samba/passdb.tdb # set -e NEWUSERNAME=$1 NEWUID=$2 NEWGID=$3 NEWHOMEDIR=$4 . /etc/adduser.conf # Ignore non-human accounts silently [ "$NEWUID" -ge "$FIRST_UID" -a "$NEWUID" -le "$LAST_UID" ] || exit 0 [ -f /etc/local/users.conf ] && . /etc/local/users.conf # Samba password #FIXME: Check if enabled in samba.conf (or included files!) if [ -x /usr/bin/pdbedit ] || [ -x /usr/bin/smbpasswd ]; then echo -n "Add samba access to the account (y/N)? " read sambaaccount case $sambaaccount in y|Y) if [ -x /usr/bin/pdbedit ]; then /usr/bin/pdbedit -a -u "$NEWUSERNAME" elif [ -x /usr/bin/smbpasswd ] && [ -f /etc/samba/smbpasswd ]; then /usr/bin/smbpasswd -a $NEWUSERNAME fi ;; esac fi # Mail forwarding if [ -x /usr/local/sbin/userforward ]; then echo -n "Forward mail to an external account (y/N)? " read mailforward case $mailforward in y|Y) echo -n "Enter external email address: " read mail_address case $mail_address in ?*@?*.*) /usr/local/sbin/userforward $NEWUSERNAME $mail_address ;; ?*) echo "That wasn't a proper email address - skipping..." ;; esac ;; esac fi # Mailing lists #FIXME: Be more generic - support other mailinglists than mailman! listdir="/var/lib/mailman/lists" lists="" [ -d $listdir ] && \ lists=`find $listdir -type d -mindepth 1 -maxdepth 1 -exec basename '{}' \;` for list in $lists; do if [ -d $listdir/$list -a -x /usr/sbin/add_members ]; then echo -n "Subscribe to mailinglist $list (y/N)? " read subscribe case $subscribe in y|Y) /bin/echo $NEWUSERNAME@`hostname -d` \ | /usr/sbin/add_members -w y -a y -r - $list ;; esac fi done if [ -f /etc/local/users.conf ]; then . /etc/local/users.conf if [ -n "$USERS_GROUPNAME" ]; then addgroup $NEWUSERNAME $USERS_GROUPNAME fi if [ -n "$REALUSERS_GROUPNAME" ]; then echo "This system has both dummy and real users:" echo " Dummy users have read access to specific files." echo " Real users have read/write access to personal files." echo -n "Is this a dummy user (Y/n)? " read realuser case $realuser in y|Y|"") ;; *) addgroup $NEWUSERNAME $REALUSERS_GROUPNAME ;; esac fi fi #if [ -n "$REALUSERS_GROUPNAME" ]; then cat <<+ Is this a remote or local user (with need for physical access to devices like CD-ROM, soundcard and modem needed)? + echo -n "Grant this user access to local utilities (y/N)?" read localuser case $localuser in y|Y) for group in floppy dialout cdrom audio video games; do addgroup $NEWUSERNAME $group done ;; *) ;; esac #fi if [ -x /usr/local/sbin/user-init ]; then /usr/local/sbin/user-init $NEWUSERNAME fi