From 7133dd4463eb4b65b6b87bf11010e583a4267d65 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 24 Feb 2002 01:21:58 +0000 Subject: A few more tweaks and corrections to adduser.local, deluser.local and user-init. --- adduser.local | 43 ++++++++++++++++++++++++++++++------------- deluser.local | 27 ++++++++++++++++++++++++--- user-init | 1 + 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/adduser.local b/adduser.local index 6c8dfbb..e946bf5 100755 --- a/adduser.local +++ b/adduser.local @@ -24,14 +24,22 @@ if [ -x /usr/local/sbin/smbadduser -a -f /etc/samba/smbpasswd -a -x /bin/csh ]; fi # Mail forwarding -#FIXME: Do some syntax checking and bail out with a warning if something wrong if [ -x /usr/local/sbin/userforward ]; then - echo -n "Forward mail to which account (leave blank to ignore)? " - read -s mailforward - echo + echo -n "Forward mail to an external account (y/N)? " + read mailforward case $mailforward in y|Y) - /usr/local/sbin/userforward $1 $mailforward + echo -n "Enter external email address: " + read mail_address + case $mail_address in + ?*@?*.*) + /usr/local/sbin/userforward $1 $mailforward + ;; + ?*) + echo "That wasn't a proper email address - skipping..." + ;; + esac + ;; esac fi @@ -43,12 +51,11 @@ lists="" 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 -s subscribe - echo + read subscribe case $subscribe in y|Y) /bin/echo $NEWUSERNAME@`/bin/dnsdomainname` \ - | /usr/sbin/add_members -n - users + | /usr/sbin/add_members -n - users ;; esac fi @@ -56,11 +63,11 @@ done #FIXME: Make this ALOT more generic (or move it to /etc/local/adduser.d)! if [ -d /home/christof/ftp_christof_ro ]; then - echo "Real users have read/write access to personal files." - echo "Dummy users have read access to published files." + echo "This seems to be a dummy/real user environment:" + echo " Real users have read/write access to personal files." + echo " Dummy users have read access to published files." echo -n "Is this a *real* user (y/N)? " - read -s realuser - echo + read realuser case $realuser in y|Y) addgroup $NEWUSERNAME realusers @@ -70,7 +77,17 @@ if [ -d /home/christof/ftp_christof_ro ]; then || mkdir /home/christof/ftp_christof_ro/$1 chown christof: /home/christof/ftp_christof_ro/$1 chmod u=rw,go=r,a+X /home/christof/ftp_christof_ro/$1 - ln -s /home/christof/ftp_christof_ro/$1 $4/images + if [ -e $4/images ]; then + if [ -L $4/images ]; then + rm -rf $4/images + ln -s /home/christof/ftp_christof_ro/$1 $4/images + else + echo "Something is wrong - $4/images exists already." + echo "This maybe isn't a dummy/real environment after all. Bailing out..." + fi + else + ln -s /home/christof/ftp_christof_ro/$1 $4/images + fi ;; esac fi diff --git a/deluser.local b/deluser.local index e8c04d8..796c12a 100755 --- a/deluser.local +++ b/deluser.local @@ -5,7 +5,17 @@ OLDUID=$2 OLDGID=$3 OLDHOMEDIR=$4 -[ "x$OLDHOMEDIR" = "x/home/$OLDUSERNAME" ] || exit 0 +if [ ! -d "$OLDHOMEDIR" ]; then + echo -n "Something's wrong - home directory doesn't exist. Continue (y/N)? " + read continue + case $continue in + y|Y) + ;; + *) + exit 1 + ;; + esac +fi if [ -e /etc/samba/smbpasswd -a -x /usr/bin/smbpasswd ]; then /usr/bin/smbpasswd -x $OLDUSERNAME || true @@ -25,11 +35,22 @@ fi #FIXME: Make this ALOT more generic! if [ -d /home/christof/ftp_christof_ro/$1 -a -n "$1" ]; then echo -n "It seems this was a dummy user. Remove shared files (y/N)? " - read -s remove_files - echo + read remove_files case $remove_files in y|Y) rm -rf /home/christof/ftp_christof_ro/$1 ;; esac fi + +# It seems deluser doesn't always remove home even if told to do so +#FIXME: Only ask if removing is enabling in /etc/deluser.conf +if [ -d $4 -a -n "$4" ]; then + echo -n "Remove old home (y/N)? " + read remove_home + case $remove_home in + y|Y) + rm -rf $4 + ;; + esac +fi diff --git a/user-init b/user-init index b144807..6afb10d 100755 --- a/user-init +++ b/user-init @@ -26,6 +26,7 @@ xchange=".xchange" [ $SAMBA_HOME ] && pc=$SAMBA_HOME [ $XCHANGE_HOME ] && xchange=$XCHANGE_HOME +echo "Creating default folders and setting permissions:" for USER in $USERS; do HOME="/home/$USER" -- cgit v1.2.3