[vhffs-dev] [450] Added default values for DB host, DB name and DB user and a message for pgsql 7.x users.

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 450
Author:   beuss
Date:     2007-02-15 21:55:16 +0000 (Thu, 15 Feb 2007)

Log Message:
-----------
Added default values for DB host, DB name and DB user and a message for pgsql 7.x users.

Modified Paths:
--------------
    branches/vhffs_4.1/vhffs-compat/updatedb.pl


Modified: branches/vhffs_4.1/vhffs-compat/updatedb.pl
===================================================================
--- branches/vhffs_4.1/vhffs-compat/updatedb.pl	2007-02-15 21:15:57 UTC (rev 449)
+++ branches/vhffs_4.1/vhffs-compat/updatedb.pl	2007-02-15 21:55:16 UTC (rev 450)
@@ -90,12 +90,15 @@
 
 my ($dbhost, $dbname, $dbuser, $dbpass);
 
-print 'Enter VHFFS DB hostname : ';
+print 'Enter VHFFS DB hostname [localhost] : ';
 chomp($dbhost = <STDIN>);
-print 'Enter VHFFS DB name : ';
+$dbhost = 'localhost' unless($dbhost);
+print 'Enter VHFFS DB name [vhffs] : ';
 chomp($dbname = <STDIN>);
-print 'Enter VHFFS DB username : ';
+$dbname = 'vhffs' unless($dbname);
+print 'Enter VHFFS DB username [vhffs] : ';
 chomp($dbuser = <STDIN>);
+$dbuser = 'vhffs' unless($dbuser);
 $dbpass = read_password('Enter VHFFS DB password : ');
 
 my $dbh = DBI->connect("DBI:Pg:dbname=$dbname;host=$dbhost;port=5432",$dbuser, $dbpass);
@@ -103,6 +106,12 @@
     die "Cant connect to VHFFS DB\n";
 }
 
+`psql --version` =~ /^.*?(\d+)/;
+my $version = $1;
+if($version == 7) {
+    print "You may be asked for you pgsql password during upgrade (psql 7.x doesn't support file authentication).\n";
+}
+
 # psql and pg_dump will not ask for a password using this
 my $pgpass = new File::Temp(DIR => '/tmp');
 print $pgpass "*:*:$dbname:$dbuser:$dbpass"; 
@@ -224,8 +233,6 @@
     $sth->execute($_->[1], $_->[0]) or warn "Unable to update user #$_->[0] (shell : $_->[1])\n";
 }
 
-print " done.\n";
-
 $rows = $dbh->selectall_arrayref('SELECT uid, firstname, lastname, address, city, country FROM vhffs_user_info', { Slice => {} });
 
 $sth = $dbh->prepare('UPDATE vhffs_user_info SET firstname = ?, lastname = ?, address = ?, city = ?, country = ? WHERE uid = ?');
@@ -236,6 +243,6 @@
     $sth->execute($_->{firstname}, $_->{lastname}, $_->{address}, $_->{city}, $_->{country}, $_->{uid}) or warn "Unable to update infos for user #$_{uid}";
 }
 
-print " done.";
+print " done.\n";
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/