#!/bin/sh
#
######################
#  BULK USER ADDING FOR QMAIL TOASTER
#
# Created after I ran into an issue of creating 20,000 users on my toaster!
# Initial ideas come from a script that PakOgah "pakogah@pala.bo-tak.info"
# helped me with.
# Still very manual, but Work in Progress
#
# Suggestions to akisakye@ucu.ac.ug
#
# Change a few variables and you are good to go
#
#######################


# Location of the users file
# Rememeber that the users file is in the format
# Firstname Lastname Username

USERS_FILE="/path/to/file.txt"

# The mail domain to which users are created
#
MAILDOMAIN="@domain.com"

# the vadduser command
QMAILADD="/home/vpopmail/bin/vadduser"

# Select a default password for all users

PASS="mypass"

#Specify the Default Quota_in_bytes for your Users

QUOTA="10000000"

#Fun starts here No more variables to change below this line

cat ${USERS_FILE} | \
while read FIRSTNAME LASTNAME USERNAME
do
  echo "adding the user: $USERNAME"
        $QMAILADD -q $QUOTA -c "$FIRSTNAME $LASTNAME" $USERNAME$MAILDOMAIN $PASS

done
