[Fusionforge-commits] r11131 - trunk/src/plugins/globalsearch/bin
Roland Mas
lolando at libremir.placard.fr.eu.org
Fri Oct 22 13:19:15 CEST 2010
Author: lolando
Date: 2010-10-22 13:19:14 +0200 (Fri, 22 Oct 2010)
New Revision: 11131
Modified:
trunk/src/plugins/globalsearch/bin/db-upgrade.pl
Log:
Use built-in Perl function rather than depending on external tool
Modified: trunk/src/plugins/globalsearch/bin/db-upgrade.pl
===================================================================
--- trunk/src/plugins/globalsearch/bin/db-upgrade.pl 2010-10-22 11:14:15 UTC (rev 11130)
+++ trunk/src/plugins/globalsearch/bin/db-upgrade.pl 2010-10-22 11:19:14 UTC (rev 11131)
@@ -11,6 +11,7 @@
use DBI ;
use MIME::Base64 ;
use HTML::Entities ;
+use Socket;
use vars qw/$dbh @reqlist $query/ ;
use vars qw/$sys_default_domain $sys_cvs_host $sys_download_host
@@ -77,27 +78,31 @@
debug "Adding local data." ;
do "/etc/gforge/local.pl" or die "Cannot read /etc/gforge/local.pl" ;
-
- my $ip_address = qx/host $domain_name | awk '{print \$3}'/ ;
-
- @reqlist = (
- # "INSERT INTO plugin_".$pluginname."_sample_data (domain, ip_address) VALUES ('$domain_name', '$ip_address')",
- ) ;
-
- foreach my $s (@reqlist) {
- $query = $s ;
- # debug $query ;
- $sth = $dbh->prepare ($query) ;
- $sth->execute () ;
- $sth->finish () ;
- }
- @reqlist = () ;
-
- &update_db_version ($target) ;
- debug "Committing." ;
- $dbh->commit () ;
+
+ my $packed_ip = gethostbyname("$domain_name");
+ my $ip_address ;
+ if (defined $packed_ip) {
+ $ip_address = inet_ntoa($packed_ip);
}
-
+
+ @reqlist = (
+ # "INSERT INTO plugin_".$pluginname."_sample_data (domain, ip_address) VALUES ('$domain_name', '$ip_address')",
+ ) ;
+
+ foreach my $s (@reqlist) {
+ $query = $s ;
+ # debug $query ;
+ $sth = $dbh->prepare ($query) ;
+ $sth->execute () ;
+ $sth->finish () ;
+ }
+ @reqlist = () ;
+
+ &update_db_version ($target) ;
+ debug "Committing." ;
+ $dbh->commit () ;
+ }
+
debug "It seems your database install/upgrade went well and smoothly. That's cool." ;
debug "Please enjoy using Debian GForge." ;
More information about the Fusionforge-commits
mailing list