#!/usr/bin/perl
$version = 2 ;

# nisAddUser
# This is the NIS post-add user script.  This script
# is run after a user has been added to the NIS password. 
# This is where you put any site specific commands required
# when adding a new user, such as setting accounting information.

# --- Initialization ---
# Deal with possible spaces in the input 
foreach $i (0 .. $#ARGV) {
   $data .= "@ARGV[$i] " ;
}
chop($data) ;

if($data eq "-v") {
    print "$version\n" ;
    exit(0) ;
}

($LOGIN, $UID, $GID, $COMMENT, $HOME, $SHELL) = split(/\:/, $data, 6) ;
print "Running site specific NIS user add script\n" ;

# Debugging flag, set to 0 to turn off debugging
$debug = 1 ;
print "DATA = $data\n" if $debug ;
print "Login = $LOGIN\n" if $debug ;
print "UID = $UID\n" if $debug ;
print "GID = $GID\n" if $debug ;
print "COMMENT = $COMMENT\n" if $debug ;
print "HOME = $HOME\n" if $debug ;
print "SHELL = $SHELL\n" if $debug ;

# ----  Add the site specific commands here  ----

#print "Copying over default files\n" ;
#`cd /home/template ;tar cf - . |(cd $HOME ;tar xf - )` ;

#print "Changing ownership\n" ;
#`chown -R $UID $HOME` ;

#print "Changing group\n" ;
#`chgrp -R $GID $HOME` ;

#print "Updating tacacs database.  REMEMBER TO CHANGE PASSWORD\n" ;
#$ext = open(TACPASS, ">> /var/tacacs/passwd") ;
#if ($ext) {
#    # File exists:  Read it
#    print TACPASS "user = $LOGIN \{\n" ;
#    print TACPASS "        chap = cleartext changeme\n" ;
#    print TACPASS "        service = ppp protocol = ip \{\}\n" ;
#    print TACPASS "\}\n" ;
#    close(TACPASS);
#}
