Created
December 29, 2009 19:02
-
-
Save ymirpl/265496 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# hash: login, uid, pass, dir, | |
sub add_user { | |
my(%args) = %{$_[0]}; | |
my $command = "adduser -m "; | |
if (defined $args{'uid'}) { | |
$command .= "-u ".$args{'uid'}; | |
} | |
if (defined $args{'dir'}) { | |
$command .= "-k ".$args{'dir'}; | |
} | |
if (defined $args{'pass'}) { | |
$command .= "-p ".crypt($args{'pass'}, "AA"); | |
} | |
$command .= " ".$args{'login'}; | |
print $command; | |
if ($? == 1) { | |
print STDERR "Can'd add user, maybe gid is taken?" | |
} | |
} | |
# args login | |
sub del_user { | |
my $login = shift; | |
system("deluser ".$login); | |
} | |
# print find_free_uid(); | |
# change_gid('couchdb', 118); | |
#print generate_password(20); | |
#print home_dir("ymir"); | |
my %user = (login => 'testuser', pass => 'password'); | |
&add_user(\%user); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment