]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/pakfire.cgi
pakfire.cgi: Bring back old logic for log displaying
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / pakfire.cgi
index f2381f03126b0463ea0ad86affe8847aab5838bd..4d6eee284c7b8d9759b0020f282c7597186f6489 100644 (file)
@@ -44,8 +44,6 @@ $cgiparams{'VALID'} = '';
 $cgiparams{'INSPAKS'} = '';
 $cgiparams{'DELPAKS'} = '';
 
-my $page_lock;
-
 sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();}
 
 &Header::getcgihash(\%cgiparams);
@@ -59,9 +57,8 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' cont
 if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) {
        my @pkgs = split(/\|/, $cgiparams{'INSPAKS'});
        if ("$cgiparams{'FORCE'}" eq "on") {
-               # Lock the page.
-               $page_lock = "1";
                &General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", @pkgs);
+               sleep(1);
        } else {
                &Header::openbox("100%", "center", $Lang::tr{'request'});
                my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs);
@@ -98,9 +95,8 @@ END
 } elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) {
        my @pkgs = split(/\|/, $cgiparams{'DELPAKS'});
        if ("$cgiparams{'FORCE'}" eq "on") {
-               # Lock the page.
-               $page_lock = "1";
                &General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", @pkgs);
+               sleep(1);
        } else {
                &Header::openbox("100%", "center", $Lang::tr{'request'});
                my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs);
@@ -136,13 +132,11 @@ END
        }
 
 } elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) {
-       # Set variable to lock the page.
-       $page_lock = "1";
        &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors");
+       sleep(1);
 } elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) {
-       # Lock the page.
-       $page_lock = "1";
        &General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors");
+       sleep(1);
 } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
        $pakfiresettings{"TREE"} = $cgiparams{"TREE"};
 
@@ -156,6 +150,7 @@ END
 
                # Update lists
                &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors");
+               sleep(1);
        }
 }
 
@@ -177,44 +172,12 @@ if ($errormessage) {
        &Header::closebox();
 }
 
-# Check if a page lock is required.
-if ($page_lock) {
-       &Header::openbox('Waiting', 1, ,);
-               print <<END;
-               <table>
-                       <tr>
-                               <td>
-                                       <img src='/images/indicator.gif' alt='$Lang::tr{'active'}' title='$Lang::tr{'active'}'>
-                               </td>
-
-                               <td>
-                                       $Lang::tr{'pakfire working'}
-                               </td>
-                       </tr>
-               </table>
-END
-       &Header::closebox();
-
-       # Infinite loop to lock the page until pakfire lockfile is present.
-       while($page_lock) {
-               unless (-e $Pakfire::lockfile) {
-                       sleep(1);
-               } else {
-                       # Release page lock.
-                       undef($page_lock);
-
-                       # Break loop.
-                       last;
-               }
-       }
-
-       # Perform page reload.
-       print "<meta http-equiv='refresh' content='1;'>\n";
-       exit;
-}
+# Check if pakfire is already running.
+#
+# The system backpipe command is safe, because no user input is computed.
+my $pid = `pidof pakfire`;
 
-# Check if pakfire is already running. In this case a lockfile is present.
-if (-e $Pakfire::lockfile) {
+if ($pid) {
        &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" );
        print <<END;
        <table>