ridotta lunghexxa user
This commit is contained in:
@@ -85,8 +85,8 @@ sub setCompanyDBSet {
|
|||||||
or die getTimeStamp("log")
|
or die getTimeStamp("log")
|
||||||
. " - pid $$ >> Could not connect to admin database: $DBI::errstr";
|
. " - pid $$ >> Could not connect to admin database: $DBI::errstr";
|
||||||
|
|
||||||
$company_db_user = sprintf "dbu%013s", $company_id;
|
$company_db_user = sprintf "dbu%08s", $company_id;
|
||||||
$company_db_name = sprintf "dbn%013s", $company_id;
|
$company_db_name = sprintf "dbn%08s", $company_id;
|
||||||
$company_db_pwd = generateRandomPassword(16);
|
$company_db_pwd = generateRandomPassword(16);
|
||||||
my $sth =
|
my $sth =
|
||||||
$dbh->prepare( "update ase_lar.companies set db_user = '"
|
$dbh->prepare( "update ase_lar.companies set db_user = '"
|
||||||
@@ -124,12 +124,9 @@ sub checkCompanyDBGrant() {
|
|||||||
$exit_rc = 0;
|
$exit_rc = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my @results = $sth->fetchrow_array;
|
my $results = $sth->fetchall_arrayref;
|
||||||
print getTimeStamp("log")
|
my @arr_res = @{$results};
|
||||||
. " - pid $$ >> query result: "
|
if ( @arr_res == 1 ) { $exit_rc = 0 }
|
||||||
. $results[0] . ".\n";
|
|
||||||
|
|
||||||
if ( ( scalar @results ) == 1 ) { $exit_rc = 0 }
|
|
||||||
}
|
}
|
||||||
$sth->finish;
|
$sth->finish;
|
||||||
|
|
||||||
@@ -177,6 +174,22 @@ sub setCompanyDBGrant() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub checkCompanyDBTables() {
|
||||||
|
my $dbh =
|
||||||
|
DBI->connect( "DBI:mysql:$db_adm;host=$db_adm_srv", 'root', $db_root_pwd )
|
||||||
|
or die getTimeStamp("log")
|
||||||
|
. " - pid $$ >> Could not connect to db server: $DBI::errstr";
|
||||||
|
|
||||||
|
my $sth_db =
|
||||||
|
$dbh->prepare( "CREATE DATABASE IF NOT EXISTS "
|
||||||
|
. $company_db_name
|
||||||
|
. " CHARACTER SET utf8 COLLATE utf8_general_ci;" )
|
||||||
|
or die getTimeStamp("log") . " - pid $$ >> $DBI::errstr";
|
||||||
|
$sth_db->execute()
|
||||||
|
or die getTimeStamp("log") . " - pid $$ >> $DBI::errstr";
|
||||||
|
$sth_db->finish;
|
||||||
|
}
|
||||||
|
|
||||||
print getTimeStamp("log") . " - pid $$ >> Execution started.\n";
|
print getTimeStamp("log") . " - pid $$ >> Execution started.\n";
|
||||||
|
|
||||||
GetOptions( "company=s" => \$company )
|
GetOptions( "company=s" => \$company )
|
||||||
@@ -190,13 +203,9 @@ if ( !checkCompanyDBSet() ) {
|
|||||||
if ( !checkCompanyDBGrant() ) {
|
if ( !checkCompanyDBGrant() ) {
|
||||||
print getTimeStamp("log") . " - pid $$ >> Set Company user DB grant.\n";
|
print getTimeStamp("log") . " - pid $$ >> Set Company user DB grant.\n";
|
||||||
setCompanyDBGrant();
|
setCompanyDBGrant();
|
||||||
|
print getTimeStamp("log") . " - pid $$ >> Set Company user DB tables.\n";
|
||||||
|
setCompanyDBTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
print $company_db_user . "\n";
|
|
||||||
print $company_db_pwd . "\n";
|
|
||||||
|
|
||||||
my @info = getpwnam('alex');
|
|
||||||
print Dumper \@info;
|
|
||||||
|
|
||||||
print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
|
print getTimeStamp("log") . " - pid $$ >> Execution ended.\n";
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
Reference in New Issue
Block a user