OK - so we are running Postfix with ClamAV, Spamassassin, & Dovcot. This really has nothing to do with the question but it may be helpful. My question is very simple. When I add a user to out mail server, we have a temp. .txt file called "user-list.txt".
When I add a user to our mail server, I become root and I "vi" that .txt file. In that file I need to enter the users info exactly
jdoe:John:Doe:1234
The above example shows his username:First name:Last Name: Last 4 of SS#. I then save the .txt file and then we have a script under /usr/local/sbin called "create_user.sh". I run this script and it will auto generate a mail account on the server for the entries I have in the "user-list.txt".
Does anyone else find this a strange way to add / manage users to your mail server?
Also - How can I ID a user on the email server? Is there a way I can find if I am deleing Bob Smith or Bryan Smith's email account? All I can see is their home dir is "bsmith" and this tells me nothing so I am scared to delete someones info. In Exchange, I can get properties of the mailbox and see who it really belongs to.
Any advice? I will post how the script looks below in case anyone can add or make any suggestions.
Code:
#!/bin/bash
# This is a script to be used to create an mail account.
# It takes information interactively, and creates a user,
# sets permissions on the home directory, and adds them to
# the proper mailing lists.
IDE_USERLIST_FILE=/tmp/userlist.txt
IDE_USERLIST=$(sort --field-separator=: ${IDE_USERLIST_FILE} | awk -F":" '{print $1}')
PREVIOUSDIR=$(pwd)
MAILMANDIR=/var/mailman
echo "----------------------------"
for u in $IDE_USERLIST; do
IDE_USERNAME=$u
IDE_FIRSTNAME=$(grep "^$IDE_USERNAME:" $IDE_USERLIST_FILE | awk -F":" '{print $2}')
IDE_LASTNAME=$(grep "^$IDE_USERNAME:" $IDE_USERLIST_FILE | awk -F":" '{print $3}')
IDE_LASTNAME_LC=$(echo $IDE_LASTNAME | tr '[:upper:]' '[:lower:]')
IDE_FULLNAME="$IDE_FIRSTNAME $IDE_LASTNAME"
IDE_SSN_DIGITS=$(grep "^$IDE_USERNAME:" $IDE_USERLIST_FILE | awk -F":" '{print $4}')
IDE_USER_EXISTS=$(grep -c "^$IDE_USERNAME:" /etc/passwd)
IDE_PASSWORD=$(echo $IDE_LASTNAME_LC$IDE_SSN_DIGIT S)
#echo -e "USERNAME:\t$IDE_USERNAME"
#echo -e "FULL NAME:\t$IDE_FULLNAME"
#echo -e "PASSWORD:\t$IDE_PASSWORD"
if [ $IDE_USER_EXISTS -eq 0 ]; then
useradd -g users -d /home/$IDE_USERNAME -s /bin/false -c "$IDE_FULLNAME" $IDE_USERNAME && echo "User account created."
cd $MAILMANDIR/bin
echo "$IDE_USERNAME@domain.org" | ./add_members -r - everyone
cd $PREVIOUSDIR
echo "$IDE_PASSWORD" | passwd $IDE_USERNAME --stdin
echo -e "USERNAME:\t$IDE_USERNAME"
echo -e "FULL NAME:\t$IDE_FULLNAME"
echo -e "PASSWORD:\t$IDE_PASSWORD"
else
echo "*** INFO: USER $IDE_USERNAME already exists! Will NOT create."
fi
echo "----------------------------"
done
history -c