Automatically add user to Ubuntu Linux and set password

I was wondering how to create a user on my system without requiring a prompt or CLI access. The following script is the result:


# Generate 12 characters long password and print it.
PASS=`$OPENSSL rand -base64 12`
echo $PASS

# Make the password usable for the useradd utility
PASS=`mkpasswd $PASS`

# Create the user
$UADD -s $SHELL -m $1 -p $PASS