public inbox for ipfire-scm@lists.ipfire.org
 help / color / mirror / Atom feed
* [git.ipfire.org] IPFire 2.x development tree branch, next, updated. 20977f0a83e41d1128570f3d88d5c861200e4094
@ 2021-10-19 18:37 Arne Fitzenreiter
  0 siblings, 0 replies; only message in thread
From: Arne Fitzenreiter @ 2021-10-19 18:37 UTC (permalink / raw)
  To: ipfire-scm

[-- Attachment #1: Type: text/plain, Size: 7008 bytes --]

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".

The branch, next has been updated
       via  20977f0a83e41d1128570f3d88d5c861200e4094 (commit)
       via  a3c9708117a60e6e49ba4bd828d3f68d0746e54d (commit)
       via  7f7f546e4ae25d75738d6c326149476d7def615a (commit)
      from  e850a61429b03cb77a9dc798e9f093500db09a87 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 20977f0a83e41d1128570f3d88d5c861200e4094
Author: Arne Fitzenreiter <arne_f(a)ipfire.org>
Date:   Tue Oct 19 18:36:32 2021 +0000

    core161: generate new qos.sh
    
    Signed-off-by: Arne Fitzenreiter <arne_f(a)ipfire.org>

commit a3c9708117a60e6e49ba4bd828d3f68d0746e54d
Author: Arne Fitzenreiter <arne_f(a)ipfire.org>
Date:   Tue Oct 19 18:35:01 2021 +0000

    core161: add pakfire.cgi
    
    Signed-off-by: Arne Fitzenreiter <arne_f(a)ipfire.org>

commit 7f7f546e4ae25d75738d6c326149476d7def615a
Author: Stefan Schantl <stefan.schantl(a)ipfire.org>
Date:   Mon Oct 18 21:09:58 2021 +0200

    pakfire.cgi: Implement logic to lock the page until pakfire has been fully launched.
    
    When performing any action which requires pakfire, the page gets locked
    with an message informing the user that pakfire is working. The page
    will be reloaded when pakfire has been launched and is doing the
    requested operation - showing the well known log output. This also
    happens when pakfire has been launched via any kind of terminal or SSH
    session and the CGI gets accessed.
    
    Internally before pakfire gets started a variable called page_lock will
    be set to lock the page. An while loop will keep the page locked until
    pakfire is launched fully and has written it's lock_file.
    
    This approach will prevent us from any kind of required time intervall
    or race conditions.
    
    Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
    Signed-off-by: Arne Fitzenreiter <arne_f(a)ipfire.org>

-----------------------------------------------------------------------

Summary of changes:
 config/rootfiles/core/161/filelists/files |  1 +
 config/rootfiles/core/161/update.sh       |  5 ++++
 html/cgi-bin/pakfire.cgi                  | 49 +++++++++++++++++++++++++++++--
 3 files changed, 53 insertions(+), 2 deletions(-)

Difference in files:
diff --git a/config/rootfiles/core/161/filelists/files b/config/rootfiles/core/161/filelists/files
index b6a7fff92..dd727ee2d 100644
--- a/config/rootfiles/core/161/filelists/files
+++ b/config/rootfiles/core/161/filelists/files
@@ -5,6 +5,7 @@ etc/suricata/suricata.yaml
 opt/pakfire/etc/pakfire.conf
 opt/pakfire/lib/functions.pl
 srv/web/ipfire/cgi-bin/index.cgi
+srv/web/ipfire/cgi-bin/pakfire.cgi
 srv/web/ipfire/cgi-bin/proxy.cgi
 srv/web/ipfire/cgi-bin/qos.cgi
 usr/bin/2to3
diff --git a/config/rootfiles/core/161/update.sh b/config/rootfiles/core/161/update.sh
index 94c3d30a3..8110070e7 100644
--- a/config/rootfiles/core/161/update.sh
+++ b/config/rootfiles/core/161/update.sh
@@ -120,6 +120,11 @@ ldconfig
 
 # Start services
 
+# Generate new qos.sh
+qosctrl stop
+qosctrl generate
+qosctrl start
+
 # remove lm_sensor config after collectd was started
 # to reserch sensors at next boot with updated kernel
 rm -f  /etc/sysconfig/lm_sensors
diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi
index 0cf522ba1..f2381f031 100644
--- a/html/cgi-bin/pakfire.cgi
+++ b/html/cgi-bin/pakfire.cgi
@@ -44,6 +44,8 @@ $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);
@@ -57,8 +59,9 @@ 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(2);
 	} else {
 		&Header::openbox("100%", "center", $Lang::tr{'request'});
 		my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs);
@@ -95,8 +98,9 @@ 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(2);
 	} else {
 		&Header::openbox("100%", "center", $Lang::tr{'request'});
 		my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs);
@@ -132,8 +136,12 @@ 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");
 } 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");
 } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
 	$pakfiresettings{"TREE"} = $cgiparams{"TREE"};
@@ -169,6 +177,43 @@ 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. In this case a lockfile is present.
 if (-e $Pakfire::lockfile) {
 	&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" );
 	print <<END;


hooks/post-receive
--
IPFire 2.x development tree

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-19 18:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 18:37 [git.ipfire.org] IPFire 2.x development tree branch, next, updated. 20977f0a83e41d1128570f3d88d5c861200e4094 Arne Fitzenreiter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox