#!/bin/bash

#
# Script to add a new user
#

# Use the on-board facilities to create an account
clear
adduser

# Remind yourself about all the different levels
echo
cat userlevels

# Now give out time
echo
echo "How much time will we give this user ?"
echo "     2 - 10 minutes	 9 - 45 minutes"
echo "     3 - 15 minutes	12 - 60 minutes"
echo "     6 - 30 minutes	18 - 90 minutes"
echo
read USERTIME
echo
PASSLINE=`tail -n 1 /etc/passwd`
USERNAME=${PASSLINE%%:*}
USERID=`id -u $USERNAME`
edquota -p guest $USERNAME
echo $USERID $USERTIME >>/etc/usertimes.backup
echo $USERID $USERTIME >>/etc/usertimes

# We did it ...
echo
echo "User information has been added to the file: newuser.log"
echo

# Update the log file
DATE=`date`
echo "$DATE : Added '$USERNAME' UID=$USERID TIME=$USERTIME" >>newuser.log

# And mail the user a first letter!
mail -s Welcome $USERNAME <hello.letter
