smeserver-webshare/root/etc/e-smith/events/actions/webshare-adduser

51 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

#!/usr/bin/perl -w
use esmith::ConfigDB;
use Apache::Htpasswd;
my $db = esmith::ConfigDB->open_ro("WebShare");
my $projectName = $ARGV[0];
my $userName = $ARGV[1];
my $password = $ARGV[2];
#------------------------------------------------------------
# Create the MultiAccessWebshare account
#------------------------------------------------------------
my $MultiAccessWebshare =
$db->get_prop( "MultiAccess", "WebShareName" || "undefined" );
my %MultiWebshares =
sort( split( /,/, $db->get_prop( "MultiAccess", "WebShares" ) || "" ) );
if ( ( "$MultiAccessWebshare" eq "$projectName" )
&& ( "%MultiWebshares" ne "" ) )
{
my $foo =
new Apache::Htpasswd("/home/e-smith/db/webshare/htpasswd.$MultiAccessWebshare");
$foo->htDelete("$userName");
$foo->{'USEMD5'} = "MD5";
$foo->htpasswd( "$userName", "$password" );
foreach my $MultiWebshares (%MultiWebshares) {
my $foo1 =
new Apache::Htpasswd("/home/e-smith/db/webshare/htpasswd.$MultiWebshares");
$foo1->htDelete("$userName");i
$foo->{'USEMD5'} = "MD5";
$foo1->htpasswd( "$userName", "$password" );
}
}
else {
#------------------------------------------------------------
# Create the webshare account
#------------------------------------------------------------
my $foo = new Apache::Htpasswd("/home/e-smith/db/webshare/htpasswd.$projectName");
$foo->{'USEMD5'} = "MD5";
$foo->htpasswd( "$userName", "$password" );
}
exit(0)