[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: [K12OSN] Bulk user help for LDAP/Samba



Sorry, I hoped you'd know what a variable was...
I wrote a sample script for your needs below ours in full:

We use this so that people in our tech department don't have to know the
exact commandline order, etc...(such as our secretary, or tech aide)
So, this is only the meat of the script...
The script prompts for info, and then applies it in this order.

#! /bin/sh
#This script will take a username on input, and add it into samba-ldap
echo "What is the user's First Name?:"
read first
echo "What is the user's Last Name?:"
read last
username=$(echo $first|cut -c1)$last
echo "Is this the username of this person?:"
echo $username|tr A-Z a-z
read answer
case $answer in
y)
uname=$(echo $username|tr A-Z a-z)
;;
n)
echo "What is the username?:"
read uname
;;
*)
echo "y or n please!...exiting"
killall addldapuser
;;
esac
echo "What group does this user belong to?:"
read group
case $group in
bhs)
gid=1004
;;
bjhs)
gid=1002
;;
bms)
gid=1001
;;
bes)
gid=1000
;;
cisco)
gid=1005
;;
sped)
gid=1008
;;
preengr)
gid=1006
;;
tech)
gid=1007
;;
*)
gid=9999
echo "Group must be bhs:bjhs:bms:bes:cisco:sped:preengr: or
tech...Exiting."
killall addldapuser
;;
esac
smbldap-useradd.pl -a -m -g $gid -c "$first $last" $uname
echo -e password\\npassword|smbldap-passwd.pl $uname
chown -Rf $uname.$gid /home/$uname
chmod -Rf og+rX-w,u+rwX /home/$uname
exit






In your case, you could read all of the variables in from a text file,
comma delimited...
For example:
A file containing use information called usserinfo:
First,last,group,password,username
Scooby,Doo,1001,hewwowaggy,sdoo


Script part:
Cat userinfo|while read line; do
first=$(echo $line|cut -f1 -d ',')
last=$(echo $line|cut -f2 -d ',')
gid=$(echo $line|cut -f3 -d ',')
password=$(echo $line|cut -f4 -d ',')
uname=$(echo $line|cut -f5 -d ',')
smbldap-useradd.pl -a -m -g $gid -c "$first $last" $uname
echo -e $password\\n$password|smbldap-passwd.pl $uname
chown -Rf $uname.$gid /home/$uname
chmod -Rf og+rX-w,u+rwX /home/$uname
done







-----Original Message-----
From: k12osn-admin redhat com [mailto:k12osn-admin redhat com] On Behalf
Of David Trask
Sent: Wednesday, June 11, 2003 4:58 PM
To: k12osn redhat com
Cc: k12osn redhat com
Subject: Re: [K12OSN] Bulk user help for LDAP/Samba

k12osn redhat com writes:
>We have a adduser script, that reads in the groupid, first, and last 
>name, and sets them as variables, and then
>adds them to the system as follows(forcing password as their password, 
>but that could also be done as a variable)
>
>smbldap-useradd.pl -a -m -g $gid -c "$first $last" $uname
>echo -e password\\npassword|smbldap-passwd.pl $uname
>chown -Rf $uname.$gid /home/$uname
>chmod -Rf og+rX-w,u+rwX /home/$uname
>
>Hope this helps...
>I believe there is an error with the above method, but it does 
>work.(smbldap-passwd.pl doesn't like it, but it accepts it...just
>complains)


This looks good, but I'm a little confused...can you give me a usage
example.....use Scooby Doo for a user for example.   does it read from a
txt file or right from the command?

David N. Trask
Technology Teacher/Coordinator
Vassalboro Community School
dtrask vcs u52 k12 me us
(207)923-3100


_______________________________________________
K12OSN mailing list
K12OSN redhat com
https://www.redhat.com/mailman/listinfo/k12osn
For more info see <http://www.k12os.org>

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.488 / Virus Database: 287 - Release Date: 06/05/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.488 / Virus Database: 287 - Release Date: 06/05/2003
 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]