Adding a user script read carefully
Found this on the web it may be able to help
#! /bin/sh
#
# This is a script for adding users to the system,
# that also will mail them a welcome message.
# by Luke Th. Bullock (lucc@anart.no) AUG 03, 1997
#
# Check user (from addluser by Scott Womer <womer@ntlug.org>)
if [ `id -u` != 0 ]; then
echo "Sorry, only root can add users to this system."
exit 1
fi
#
# Set the system envar
SYS="/usr/sbin"
#
# Print the Help message
#
if [ "$1" = -h ]; then
cat << EOF
Newuser Script v0.2 (03AUG1997)
by Luke Th. Bullock (lucc@anart.no)
This script requires the files "adduser" and "mail".
To add a new user, specify the login name at the prompt:
"newuser harry" (without the quotes).
Then fill in the questionaire with the appropriate data
for the new user. This script will also, after adding the
new account, send a Welcome Message to the new user, and
add the user to the file /root/accounts for log purposes.
EOF
unset SYS
exit
fi
#
# Search for adduser
#
if [ -f ${SYS}/adduser ]; then
ADD=${SYS}/adduser
else
echo "Cannot find required file \"adduser\" in $SYS."
echo "Please type \"newuser help\" for more info."
unset SYS
exit
fi
# All is well, add the user and send the welcome mail.
#
if [ "$1" ]; then
$ADD
# Send the email to the user
#
cat << EOF |mail -s 'Welcome New User' $1
Welcome New User
If you have any questions, send an email to root,
or to support. If you wish to make a home page,
make the directory public_html/, chmod it 755,
then cd public_html, create the file index.html
and chmod it 644. Now you are set, create your pages.
Ask root or support for your disc quota, normally
it should be 5MB.
System Admin
EOF
#
# Keep a log of new users
echo $1 >> /root/accounts
#
# Sleep for 3 secs while the system does it's stuff..
sleep 3
# Finger the user to see all is correct
finger $1
#
else # If no arg is used, print a short explanation
echo "usage: newuser \"user\" (type "newuser -h" for help)"
unset SYS
fi
#
#End of Script
|