mvhub-dev team mailing list archive
-
mvhub-dev team
-
Mailing list archive
-
Message #00221
[Branch ~mvhub-commit/mvhub/trunk] Rev 390: ran perltidy
------------------------------------------------------------
revno: 390
committer: Dan MacNeil <dan@xxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-05-28 17:15:51 -0400
message:
ran perltidy
modified:
lib-mvhub/lib/MVHub/Utils/Setup.pm
--
lp:mvhub
https://code.launchpad.net/~mvhub-commit/mvhub/trunk
Your team MVHub Developers is subscribed to branch lp:mvhub.
To unsubscribe from this branch go to https://code.launchpad.net/~mvhub-commit/mvhub/trunk/+edit-subscription
=== modified file 'lib-mvhub/lib/MVHub/Utils/Setup.pm'
--- lib-mvhub/lib/MVHub/Utils/Setup.pm 2010-05-21 20:01:19 +0000
+++ lib-mvhub/lib/MVHub/Utils/Setup.pm 2010-05-28 21:15:51 +0000
@@ -14,20 +14,20 @@
use MVHub::Utils::DB;
our @EXPORT_OK = qw(
- @SITE_CODES
- add_apache_config
- add_dns
- get_production_data
- get_testing_data
- make_config_files_for
- make_database_user
- make_databases_for
- make_dirs_from
- load_production_data
- load_test_data_for
- remove_cron_jobs
- restart_services
- update_etc_files
+ @SITE_CODES
+ add_apache_config
+ add_dns
+ get_production_data
+ get_testing_data
+ make_config_files_for
+ make_database_user
+ make_databases_for
+ make_dirs_from
+ load_production_data
+ load_test_data_for
+ remove_cron_jobs
+ restart_services
+ update_etc_files
);
our @SITE_CODES = qw/ mvh nsp /;
@@ -37,20 +37,20 @@
my $tmp_file = "$file.tmp";
open( IN, $file )
- or die "bad open: $file error: $! \n";
+ or die "bad open: $file error: $! \n";
my @lines = <IN>;
close(IN) or die "bad close $file error: $!\n";
push @lines, $append_lines;
open( OUT, ">", "$tmp_file" )
- or die "couldn't open $tmp_file.tmp error: $! \n";
+ or die "couldn't open $tmp_file.tmp error: $! \n";
( print OUT @lines )
- or die "couldn't write to $tmp_file $!\n";
+ or die "couldn't write to $tmp_file $!\n";
close(OUT) or die "couldn't close $tmp_file $!\n";
File::Copy::move( $tmp_file, $file )
- or die "couldn't rename $tmp_file to $file\n";
+ or die "couldn't rename $tmp_file to $file\n";
}
sub _add_calculable_values {
@@ -58,10 +58,11 @@
my $username = shift or croak 'missing param: $username';
my $site_code = shift or croak 'missing param: $site_code';
- $template_cfg->param( 'DATABASE.database_name', "$username.$site_code" );
- $template_cfg->param( 'DATABASE.database_user', "$username" );
- $template_cfg->param( 'NOTIFICATION.admin_email', "$username\@thecsl.org" );
- $template_cfg->param( 'NOTIFICATION.dev_email', "$username\@thecsl.org" );
+ $template_cfg->param( 'DATABASE.database_name', "$username.$site_code" );
+ $template_cfg->param( 'DATABASE.database_user', "$username" );
+ $template_cfg->param( 'NOTIFICATION.admin_email',
+ "$username\@thecsl.org" );
+ $template_cfg->param( 'NOTIFICATION.dev_email', "$username\@thecsl.org" );
$template_cfg->param( 'SITE.website_name',
"$site_code.$username.testing123.net" );
$template_cfg->param( 'SITE.website_code', "$site_code" );
@@ -125,8 +126,8 @@
usename = ?
SQL
- my $matching_db_users_aref =
- $dbh->selectall_arrayref( $sql, {}, ($username) );
+ my $matching_db_users_aref
+ = $dbh->selectall_arrayref( $sql, {}, ($username) );
return scalar @$matching_db_users_aref;
}
@@ -143,10 +144,10 @@
rolname = ?
SQL
- my $role_rows_aref =
- $dbh->selectall_arrayref( $sql, { Slice => {} }, ($username) );
+ my $role_rows_aref
+ = $dbh->selectall_arrayref( $sql, { Slice => {} }, ($username) );
my $result = $$role_rows_aref[0]{rolcreaterole}
- && $$role_rows_aref[0]{rolcreatedb};
+ && $$role_rows_aref[0]{rolcreatedb};
return $result ? 1 : 0;
}
@@ -164,8 +165,8 @@
rolname = ?
SQL
- my $role_rows_aref =
- $dbh->selectall_arrayref( $sql, { Slice => {} }, ($username) );
+ my $role_rows_aref
+ = $dbh->selectall_arrayref( $sql, { Slice => {} }, ($username) );
return $$role_rows_aref[0]{rolsuper} ? 1 : 0;
}
@@ -186,7 +187,7 @@
$cmd =~ s/^\s+//;
my @cmd = split /\s+/, $cmd;
( system(@cmd) == 0 )
- or die "$cmd failed ABORTING\n";
+ or die "$cmd failed ABORTING\n";
}
sub _get_dbh_for_template1_db {
@@ -207,7 +208,7 @@
);
my $dbh = DBI->connect( $data_source, $database_username, $auth, \%attr )
- or die "couldn't connect to database";
+ or die "couldn't connect to database";
return $dbh;
}
@@ -234,10 +235,10 @@
my $filename = shift or croak 'missing Param $filename';
open my $out_fh, '>', $filename
- or die "failed to open $filename for writing error:$!\n";
+ or die "failed to open $filename for writing error:$!\n";
print $out_fh "#Config file\n [ignore]\n";
close $out_fh
- or die "failed to close $filename error:$!\n";
+ or die "failed to close $filename error:$!\n";
return 1;
}
@@ -268,7 +269,7 @@
my $filename = shift or croak 'missing parameter: $filename';
open my $in_fh, $filename
- or die "failed to open $filename error:$!";
+ or die "failed to open $filename error:$!";
my @contents = <$in_fh>;
my $regex = qr/$host/;
@@ -287,7 +288,8 @@
}
elsif ( $output =~ /ROLLBACK/ ) {
print "FAIL\n";
- print "The following OUTPUT occured while processing $filename:\n";
+ print
+ "The following OUTPUT occured while processing $filename:\n";
die "$output\n\n****Processing $filename FAILED****\n";
}
}
@@ -345,8 +347,9 @@
my @website_codes = @_;
foreach my $prefix (@website_codes) {
- my $update_user_cfg_filename =
- _determine_user_config_filename_from( $username, $prefix, $cfg );
+ my $update_user_cfg_filename
+ = _determine_user_config_filename_from( $username, $prefix,
+ $cfg );
my $update_user_cfg = MVHub::Utils::ConfigSimple::create_config_from(
$update_user_cfg_filename);
my $dbh = MVHub::Utils::DB::get_dbh($update_user_cfg_filename);
@@ -373,8 +376,8 @@
my $dbh = shift;
my $version;
- my $exist_sql =
-"SELECT 1 FROM information_schema.tables WHERE table_name='version_log' LIMIT 1";
+ my $exist_sql
+ = "SELECT 1 FROM information_schema.tables WHERE table_name='version_log' LIMIT 1";
my $table_exists = ( $dbh->selectrow_array($exist_sql) )[0];
if ($table_exists) {
@@ -405,7 +408,7 @@
}
else {
die
-"ERROR: '$script' does not conform to naming standard: nnn_word_description.sql\n";
+ "ERROR: '$script' does not conform to naming standard: nnn_word_description.sql\n";
}
}
return sort @scripts;
@@ -415,50 +418,42 @@
my $base_dir = shift or croak 'missing param: $base_dir';
my $username = shift or croak 'missing param: $username';
my @dirs = (
- {
- dir => 'conf',
- owner => '',
- group => '',
- permissions => 'u=rwx,g=rwsx,o=rx',
- },
- {
- dir => 'cover_db',
- owner => '',
- group => '',
- permissions => 'u=rwx,g=rwsx,o=rx',
- },
- {
- dir => 'reports',
+ { dir => 'conf',
+ owner => '',
+ group => '',
+ permissions => 'u=rwx,g=rwsx,o=rx',
+ },
+ { dir => 'cover_db',
+ owner => '',
+ group => '',
+ permissions => 'u=rwx,g=rwsx,o=rx',
+ },
+ { dir => 'reports',
owner => '',
group => '',
permissions => 'u=rwx,g=rwsx,o=r-x',
},
- {
- dir => 'reports',
- owner => '',
- group => '',
- permissions => 'u=rwx,g=rwsx,o=rx',
- },
- {
- dir => 'source-code',
- owner => '',
- group => '',
- permissions => 'u=rwx,g=rwsx,o=rx',
- },
- {
- dir => 'log/mvh',
- owner => '',
- group => '',
- permissions => 'u=rwx,g=rwsx,o=rx',
- },
- {
- dir => 'log/nsp',
- owner => '',
- group => '',
- permissions => 'u=rwx,g=rwsx,o=rx',
- },
- {
- dir => 'tmp',
+ { dir => 'reports',
+ owner => '',
+ group => '',
+ permissions => 'u=rwx,g=rwsx,o=rx',
+ },
+ { dir => 'source-code',
+ owner => '',
+ group => '',
+ permissions => 'u=rwx,g=rwsx,o=rx',
+ },
+ { dir => 'log/mvh',
+ owner => '',
+ group => '',
+ permissions => 'u=rwx,g=rwsx,o=rx',
+ },
+ { dir => 'log/nsp',
+ owner => '',
+ group => '',
+ permissions => 'u=rwx,g=rwsx,o=rx',
+ },
+ { dir => 'tmp',
owner => '',
group => '',
permissions => 'u=rwx,g=rwsx,o=rx',
@@ -466,9 +461,9 @@
);
foreach my $dir_href (@dirs) {
$dir_href->{owner} = $username
- if not $dir_href->{owner};
+ if not $dir_href->{owner};
$dir_href->{group} = $username
- if not $dir_href->{group};
+ if not $dir_href->{group};
$dir_href->{dir} = "$base_dir/$username/" . $dir_href->{dir};
}
@@ -491,8 +486,8 @@
$cmd .= "/tmp/${site_code}_production_data.dump";
( system($cmd) == 0 )
- or die
- "Failed to rsync ${timestamp}_${site_code}_production_db.sql\n";
+ or die
+ "Failed to rsync ${timestamp}_${site_code}_production_db.sql\n";
}
print "done\n";
}
@@ -506,18 +501,19 @@
print "Loading production data...";
foreach my $suffix (@website_codes) {
- my $cfg_filename =
- _determine_user_config_filename_from( $username, $suffix, $cfg );
- my $user_cfg =
- MVHub::Utils::ConfigSimple::create_config_from($cfg_filename);
+ my $cfg_filename
+ = _determine_user_config_filename_from( $username, $suffix,
+ $cfg );
+ my $user_cfg
+ = MVHub::Utils::ConfigSimple::create_config_from($cfg_filename);
_set_db_ENV_vars($user_cfg);
- $cmd =
-"pg_restore -O -x -d $username.$suffix /tmp/${suffix}_production_data.dump >/dev/null";
+ $cmd
+ = "pg_restore -O -x -d $username.$suffix /tmp/${suffix}_production_data.dump >/dev/null";
( system($cmd) == 0 )
- or warn "failed to load ${suffix}_production_data.dump";
+ or warn "failed to load ${suffix}_production_data.dump";
}
print "done\n";
}
@@ -527,23 +523,25 @@
my $cfg = shift or croak 'missing param: $cfg';
my @website_codes = @_;
- my $path_to_project_tools = $cfg->param('ABSOLUTE_PATH.project_tools_dir');
+ my $path_to_project_tools
+ = $cfg->param('ABSOLUTE_PATH.project_tools_dir');
my $cmd;
print "Loading test data...";
foreach my $suffix (@website_codes) {
- my $cfg_filename =
- _determine_user_config_filename_from( $username, $suffix, $cfg );
- my $user_cfg =
- MVHub::Utils::ConfigSimple::create_config_from($cfg_filename);
+ my $cfg_filename
+ = _determine_user_config_filename_from( $username, $suffix,
+ $cfg );
+ my $user_cfg
+ = MVHub::Utils::ConfigSimple::create_config_from($cfg_filename);
_set_db_ENV_vars($user_cfg);
- $cmd =
- "psql -f ${path_to_project_tools}/test_${suffix}_db.sql >/dev/null";
+ $cmd
+ = "psql -f ${path_to_project_tools}/test_${suffix}_db.sql >/dev/null";
( system($cmd) == 0 )
- or warn "failed to load data for $username.$suffix";
+ or warn "failed to load data for $username.$suffix";
}
print "done\n";
}
@@ -554,15 +552,16 @@
my @website_codes = @_;
my @keys_for_user_generated_values = qw/ DATABASE.database_magic_word /;
- my $template_config_file =
- $cfg->param('ABSOLUTE_PATH.template_conf_dir') . "/template.conf";
+ my $template_config_file
+ = $cfg->param('ABSOLUTE_PATH.template_conf_dir') . "/template.conf";
my $template_cfg = new Config::Simple($template_config_file)
- or die "failed to create config object from $template_config_file";
+ or die "failed to create config object from $template_config_file";
foreach my $site_code (@website_codes) {
- my $cfg_filename =
- _determine_user_config_filename_from( $username, $site_code, $cfg );
+ my $cfg_filename
+ = _determine_user_config_filename_from( $username, $site_code,
+ $cfg );
my $user_cfg = new Config::Simple( syntax => 'ini' );
if ( !-e $cfg_filename ) {
_make_empty_config_file_named($cfg_filename);
@@ -574,8 +573,8 @@
$template_cfg = _add_site_specific_values( $template_cfg, $username,
%site_specific_values );
- $template_cfg =
- _add_calculable_values( $template_cfg, $username, $site_code );
+ $template_cfg
+ = _add_calculable_values( $template_cfg, $username, $site_code );
$template_cfg = _add_user_generated_values( $template_cfg, $user_cfg,
@keys_for_user_generated_values );
@@ -592,8 +591,8 @@
my $dbh = _get_dbh_for_template1_db($cfg);
if ( !_db_user_found( $dbh, $username ) ) {
- my $sql =
- "CREATE USER $username WITH PASSWORD 'test' CREATEDB CREATEROLE";
+ my $sql
+ = "CREATE USER $username WITH PASSWORD 'test' CREATEDB CREATEROLE";
$dbh->do($sql);
}
}
@@ -611,7 +610,7 @@
if ( !_db_user_has_needed_roles( $dbh, $user_running_cmd ) ) {
warn
-"\nSkipping db stuff $user_running_cmd lacks CREATEDB or CREATEROLE\n";
+ "\nSkipping db stuff $user_running_cmd lacks CREATEDB or CREATEROLE\n";
return;
}
@@ -635,8 +634,8 @@
# kludge to avoid 'db being currently being accessed' errs
sleep 1;
- $sql =
-qq{CREATE DATABASE "$username.${suffix}" OWNER "$username" ENCODING='SQL_ASCII' };
+ $sql
+ = qq{CREATE DATABASE "$username.${suffix}" OWNER "$username" ENCODING='SQL_ASCII' };
$dbh->do($sql);
}
@@ -651,17 +650,17 @@
print "Updating $username directory structure...";
foreach my $dir_href (@dir_hrefs) {
my $mkdir_cmd = "mkdir -p $dir_href->{dir}";
- my $chown_cmd =
- "chown -R $dir_href->{owner}:$dir_href->{group} $dir_href->{dir}";
+ my $chown_cmd
+ = "chown -R $dir_href->{owner}:$dir_href->{group} $dir_href->{dir}";
if ( $dir_href->{dir} =~ /log/ ) {
- # root owns log files it creates don't try to change ownership on them
- $chown_cmd =
- "chown $dir_href->{owner}:$dir_href->{group} $dir_href->{dir}";
+ # root owns log files it creates don't try to change ownership on them
+ $chown_cmd
+ = "chown $dir_href->{owner}:$dir_href->{group} $dir_href->{dir}";
}
else {
- $chown_cmd =
- "chown -R $dir_href->{owner}:$dir_href->{group} $dir_href->{dir}";
+ $chown_cmd
+ = "chown -R $dir_href->{owner}:$dir_href->{group} $dir_href->{dir}";
}
my $chmod_cmd = "chmod $dir_href->{permissions} $dir_href->{dir}";
_do_or_die($mkdir_cmd);