LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 08-15-2006, 01:43 PM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
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
 
Old 08-15-2006, 04:33 PM   #2
ad5by
LQ Newbie
 
Registered: Apr 2006
Posts: 2

Rep: Reputation: 0
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.
 
Old 08-24-2006, 11:50 AM   #3
benjithegreat98
Senior Member
 
Registered: Dec 2003
Location: Shelbyville, TN, USA
Distribution: Fedora Core, CentOS
Posts: 1,019

Rep: Reputation: 45
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any net admins, need some quick help genlee General 2 01-10-2006 06:26 PM
To the admins: chris318 Slackware 8 03-02-2005 08:42 PM
Domain Admins not Local ADmins - Samba 3.0.7 dlublink Linux - Networking 2 03-01-2005 11:05 AM
for all Slack admins... zeky Linux - Distributions 2 08-25-2002 11:02 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 09:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration