[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Sheflug] addstudent



Hi All

This is my addstudent script changed the location of smbpasswd 
to /etc/samba/smbpasswd that is may be used with Webmin

cheers

fred

#! /bin/bash

# /sbin/addstudent 
# 
# Create a new student account invoke like: 
#     addstudent [name] [password] 

PATH=/bin:/sbin:/usr/bin:/usr/sbin 
NAME=$1 
PASSWD=${2:-student} 
# Define error message 
usage () 
{ 
    echo " " 
    echo "Usage: addstudent [name] [password]" 
    echo "       If password is not specified" 
    echo "       it defaults to \"student\"" 
    echo " " 
}

# Test for username
if [ -z "$NAME" ]; then 
    usage 
    exit 1 
fi 

# User exists? 
if id $NAME > /dev/null 2>&1; then 
    echo " " 
    echo "User exists!" 
    echo " " 
    exit 1 
fi 

# Run the real useradd command 
if useradd -d /home/students/$NAME -g students -p `echo "print crypt
('$PASSWD', 'RH');" | perl` $NAME; then
    # Adding user to /etc/samba/smbpasswd 
    echo "$PASSWD" > /etc/samba/smbpwd 
    echo "$PASSWD" >> /etc/samba/smbpwd 
    smbpasswd -s -a $NAME < /etc/samba/smbpwd 
    rm -f /etc/samba/smbpwd
    echo " " 
    echo "Success!" 
    echo "Added the user: $NAME" 
    echo "With password:  $PASSWD" 
    echo " " 
    # Set permissons for the home directory 
    chmod -R 2770 /home/students/$NAME 
    chown -R `id -u $NAME`.teachers /home/students/$NAME 
    # Set quotas 
    edquota -p quotastudent $NAME
else 
   echo " " 
   echo "Oops, something went wrong!" 
   echo " " 
fi
---------------------------------------------------
This e-mail and any files transmitted with it are
confidential and intended solely for the use of the
individual or entity to whom they are addressed. If
you have received this email in error please notify
the sender immediately.

Any views or opinions expressed in this e-mail are 
those of the sender and do not necessarily coincide
with those of North Trafford College.
___________________________________________________________________

Sheffield Linux User's Group - http://www.sheflug.co.uk . 
To unsubscribe from this list send mail to 
shef-lug-request@list.sheflug.org.uk with the word
"unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.