LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Email Admins - I have a Question (https://www.linuxquestions.org/questions/linux-enterprise-47/email-admins-i-have-a-question-474129/)

carlosinfl 08-15-2006 01:43 PM

Email Admins - I have a Question
 
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


ad5by 08-15-2006 04:33 PM

re: Email Admins - I have a Question
 
I have seen a lot of scripts used to create accounts. When you are dealing with hundreds or even thousands of email addresses created in bulk, a script is the only sane way of doing it. Redhat/Fedora even has a script with the distro called newusers. The script you posted isn't necessarily what I would build, but if it does the job...

As far as determining the full name of the user, try typing: finger bsmith <enter> from the command line and it should return the info you are looking for.

benjithegreat98 08-24-2006 11:50 AM

Also for the full name info, in addition to the finger command, that info should be stored in /etc/passwd . Or it is on my system anyways.


All times are GMT -5. The time now is 11:38 PM.