$cgiparams{'INSPAKS'} = '';
$cgiparams{'DELPAKS'} = '';
-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);
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
&Header::openpage($Lang::tr{'pakfire configuration'}, 1);
&Header::openbigbox('100%', 'left', '', $errormessage);
-if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) {
+if (($cgiparams{'ACTION'} eq 'install') && (! &_is_pakfire_busy())) {
my @pkgs = split(/\|/, $cgiparams{'INSPAKS'});
if ("$cgiparams{'FORCE'}" eq "on") {
&General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", @pkgs);
&Header::closepage();
exit;
}
-} elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) {
+} elsif (($cgiparams{'ACTION'} eq 'remove') && (! &_is_pakfire_busy())) {
my @pkgs = split(/\|/, $cgiparams{'DELPAKS'});
if ("$cgiparams{'FORCE'}" eq "on") {
&General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", @pkgs);
exit;
}
-} elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) {
+} elsif (($cgiparams{'ACTION'} eq 'update') && (! &_is_pakfire_busy())) {
&General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors");
sleep(1);
-} elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) {
+} elsif (($cgiparams{'ACTION'} eq 'upgrade') && (! &_is_pakfire_busy())) {
&General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors");
sleep(1);
} elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
}
# Check if pakfire is already running.
-#
-# The system backpipe command is safe, because no user input is computed.
-my $pid = `pidof pakfire`;
-
-if ($pid) {
+if (&_is_pakfire_busy()) {
&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" );
print <<END;
<table>
&Header::closebigbox();
&Header::closepage();
exit;
- refreshpage();
}
my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`;
&Header::closebox();
&Header::closebigbox();
&Header::closepage();
+
+###--- Internal functions ---###
+
+# Check if pakfire is already running (extend test here if necessary)
+sub _is_pakfire_busy {
+ # Get PID of a running pakfire instance
+ # (The system backpipe command is safe, because no user input is computed.)
+ my $pakfire_pid = `pidof -s /usr/local/bin/pakfire`;
+ chomp($pakfire_pid);
+
+ # Test presence of PID or lockfile
+ return (($pakfire_pid) || (-e "$Pakfire::lockfile"));
+}