Need to add several thousand user-names, several hundred group-names, make users part of groups, etc., and am battling . . .
I have tried script as per Darryl May (Thanks), but don't seem to be able 2 get it 2 work properly with SME v5.1.2
After running script, 'db show accounts' lists the added account and pseudonyms, but /home directory is not created, unix account is not created, password not set, ldap and httpd not updated??? What am I doing wrong??
Herewith modded script to add students:-
      #!/bin/sh
      #
      # USAGE:
      #
      # Create the file /root/stlist.txt in the following format:
      #
      # USERNAME1
      #
      # and so on...
      #
      # This script will create user accounts, mail accounts and pseudonyms for 
      # all the listed users in the /root/stlist.txt file.
      #
      # NOTE *By default usernames/passwords are set to the same value*
      #
      UFILE=$1
      if [ ! -f $UFILE ]; then
      echo User database $UFILE missing
      exit
      fi 
      # export record=cat $UFILE
      # if [ "$record" != "" ]; then
      # --------------------------
      # Make sure the lines below are all indented as shown
      # --------------------------
         for record in cat $UFILE
         do
         user=echo $record | awk -F"," {'print $1'}
         firstname=student
         lastname=echo $record | awk -F"," '{print "#" substr($1,2,length($1))}'
         uid=echo $record | awk -F"," '{print substr($1,4)}'
         number=$RANDOM 
      # ----------------------
      # Set values for account
      # ----------------------
      #
      # Available values and options are shown below as 'option' :
      #
      # FirstName $firstname
      # LastName $lastname
      # Dept 'department'
      # Company 'company name'
      # Street 'address'
      # City 'city, postal, prov/state, country' 
      # Phone 'phone number' 
      # EmailForward 'local, forward, both'
      # ForwardAddress 'leave blank or enter forward address'
      #
      # Below are the minimum values with no changes required
      #
      /sbin/e-smith/db accounts set UserName $user FirstName $firstname LastName $lastname PasswordSet yes Uid $uid Gid $number 
      # ---------------
      # Create e-smith Account
      # ---------------
      /sbin/e-smith/signal-event user-create $user
#  tried adding this - error on 
#  unless db_get_type(\%accounts, $username) eq "user" - line 47
      # Create Unix Acct
     
       /etc/e-smith/events/user-create/S15user-create-unix UserName $user
     
      # ---------------
      # Pause Script, bug reported by Jeffrey Smith
      # ---------------
      sleep 9
      # ----------------
      # Create Password
      # -----------------------------------------------------
      # (in this case the username and password are the same)
      # eg: ( '$username', 'PASSWORD' );"
      # -----------------------------------------------------
      perl -e "use esmith::util; esmith::util::setUserPassword ( '$user', 
      '$user' );" 
      # ---------------------------------
      # Set value for password as created
      # ---------------------------------
      /sbin/e-smith/db accounts setprop $user PasswordSet yes 
      # ---------------------------------------------------------
      # Create Pseudonym (FIRSTNAME.LASTNAME@domain.org)
      # Create Pseudonym (FIRSTNAME_LASTNAME@domain.org)
      # (simple comment these lines out to not create Pseudonyms)
      # ---------------------------------------------------------
      /sbin/e-smith/signal-event pseudonym-create $firstname.$lastname $user
      /sbin/e-smith/signal-event pseudonym-create $firstname_$lastname $user
      done
input file looks like :-
s970871234
to give
Account Name : s970871234
First Name : student
Last Name : # 970871234
password : s97081234
Been at this for a week now - would appreciate some help :-0
Thanks,
Ivan