From 28593a79c2db39a88e28e3e22be975eaa028fb21 Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Sat, 19 Apr 2008 14:49:00 +0200 Subject: [PATCH] Changed the behaviour of the pakfire cgi Tried to handle some known pakfire problems (time errors and zero metas) --- html/cgi-bin/pakfire.cgi | 9 ++++----- src/pakfire/lib/functions.pl | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi index 2a49463752..79bb3fb887 100644 --- a/html/cgi-bin/pakfire.cgi +++ b/html/cgi-bin/pakfire.cgi @@ -136,13 +136,11 @@ END } elsif ($pakfiresettings{'ACTION'} eq 'update') { - system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null"); + system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null &"); } elsif ($pakfiresettings{'ACTION'} eq 'upgrade') { - my $command = "/usr/local/bin/pakfire upgrade -y --no-colors &>/dev/null"; + my $command = "/usr/local/bin/pakfire upgrade -y --no-colors &>/dev/null &"; system("$command"); - refreshpage(); - } elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}") { if ($pakfiresettings{'AUTOUPDATE'} eq 'on') { @@ -198,7 +196,7 @@ if ($return) {
 END
-	my @output = `tail -20 /var/log/pakfire.log`;
+	my @output = `grep pakfire /var/log/messages | tail -20`;
 	foreach (@output) {
 		print "$_";
 	}
@@ -210,6 +208,7 @@ END
 	&Header::closebigbox();
 	&Header::closepage();
 	exit;
+	refreshpage();
 }
 
 my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`;
diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl
index 1080b00621..c8febe76e6 100644
--- a/src/pakfire/lib/functions.pl
+++ b/src/pakfire/lib/functions.pl
@@ -118,7 +118,7 @@ sub pinghost {
 	
 	$p = Net::Ping->new();
   if ($p->ping($host)) {
-  	logger("PING INFO: $host is alive");
+ 	 logger("PING INFO: $host is alive");
   	return 1;
   } else {
 		logger("PING INFO: $host is unreachable");
@@ -211,6 +211,9 @@ sub fetchfile {
 						move("$Conf::tmpdir/$bfile","$Conf::cachedir/$bfile");
 					} else {
 						message("DOWNLOAD ERROR: The downloaded file ($file) wasn't verified by IPFire.org. Sorry - Exiting...");
+						my $ntp = `ntpdate -q -t 10 pool.ntp.org 2>/dev/null | tail -1`;
+						if ( $ntp !~ /time\ server(.*)offset(.*)/ ){message("TIME ERROR: Unable to get the nettime, this may lead to the verification error.");}
+						else { $ntp =~ /time\ server(.*)offset(.*)/; message("TIME INFO: Time Server$1has$2 offset to localtime.");}
 						exit 1;
 					}
 					logger("DOWNLOAD FINISHED: $file");
@@ -544,7 +547,12 @@ sub cleanup {
 sub getmetafile {
 	my $pak = shift;
 	
-	unless ( -e "$Conf::dbdir/meta/meta-$pak") {
+	unless ( -e "$Conf::dbdir/meta/meta-$pak" ) {
+		fetchfile("meta/meta-$pak", "");
+		move("$Conf::cachedir/meta-$pak", "$Conf::dbdir/meta/meta-$pak");
+	}
+	
+	if ( -z "$Conf::dbdir/meta/meta-$pak" ) {
 		fetchfile("meta/meta-$pak", "");
 		move("$Conf::cachedir/meta-$pak", "$Conf::dbdir/meta/meta-$pak");
 	}
-- 
2.39.2