#!/usr/bin/perl
use Linux::usermod;
use Getopt::Std;
use File::Basename;
getopt('u:n:p:s:h:c:k:a:d:A:D:');

$proname = basename($0);
if(!opt_a or !$opt_d or !$opt_b){
	die &usage unless $opt_u && $opt_p || 
	$opt_L || 
	$opt_U || 
	$opt_c || 
	$opt_h || 
	$opt_s || 
	$opt_n || 
	$opt_a || 
	$opt_d || 
	$opt_b || 
	$opt_A || 
	$opt_D
}
Linux::usermod->add($opt_a) and exit if $opt_a;
Linux::usermod->del($opt_d) and exit if $opt_d;
Linux::usermod->grpadd($opt_A) and exit if $opt_A;
Linux::usermod->grpdel($opt_D) and exit if $opt_D;
$user = Linux::usermod->new($opt_u);
die "No such user\n" unless  defined $user->get(uid);
$user->set(password, $opt_p) if $opt_p;
$user->set(comment, $opt_c) if $opt_c;
$user->set(home, $opt_h) if $opt_h;
$user->set(shell, $opt_s) if $opt_s;
$user->set(name, $opt_n) if $opt_n;
$user->tobsd() if $opt_b;
$user->lock if $opt_L;
$user->unlock if $opt_U;
sub usage{ 
	print <<SQ;
$proname:
	-n name
	-a add
	-d delete
	-b to bsd style
	-h home
	-s shell
	-c comment
	-p new_password
	-U unlock
	-L lock
	-u username
	-A groupname
	-D groupname
SQ
	exit 0
}


