From patchwork Thu Dec 2 15:39:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 4888 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4J4gBq0f5Cz3wg9 for ; Thu, 2 Dec 2021 15:40:19 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4J4gBl47R6zjr; Thu, 2 Dec 2021 15:40:15 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4J4gBl2SlSz2yW0; Thu, 2 Dec 2021 15:40:15 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4J4gBj0xpxz2xWY for ; Thu, 2 Dec 2021 15:40:13 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4J4gBb23g1znR for ; Thu, 2 Dec 2021 15:40:07 +0000 (UTC) Received: (qmail 21995 invoked from network); 2 Dec 2021 15:40:05 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 2 Dec 2021 15:40:05 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH 1/4] pakfire.cgi: Extend the lockfile test Date: Thu, 2 Dec 2021 16:39:52 +0100 Message-Id: <20211202153955.1126-1-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1638459607; a=rsa-sha256; cv=none; b=OdStOSXYx9xhFbbGxNejgPXSEBiruYeuN7JN5yTMmIg7omRY52K+yvpL40hUGR+DJQ9o6N ykpncFIjGSQV6pPVs/mY9u/Bs2b6jtf3AKI2m3MfI7IysZeIeIKwBMUq1eVt2OU6YnlrqW TKod91BHTcQauL+uyDm0Ne+x/2OW2PNtMM2+jvAe+2FjH2vQ5fD0aNuy3r6hxDRopwdhHi 18fct1OYe8kqHCJC0B8u0xGQfm1HkZDxblKubCs63Wh+VwVFYsePqiXb5bjie6cuvlNjEb 5o65/9HBRwSW4k74K6wQv6ZOmQ0Gcy97sQeIZtoLT3hzzv6qehI5qM0tdaJoiQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=pass (policy=none) header.from=leo-andres.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1638459607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MFzmHEMKjdBRT3ZTISsPkEBQ1XwFu+b1U/UutSlG/pU=; b=b25d64EXetSx8EQH/iGfXTTND2e8XoQL5snt4/MY+UJy3bi6eMZtNtMhhRkL4/mgfjJHkr QofOJqwQe0iyNU8Wz1MhNM5O/X+c2Pa1gJsJDv5jAUS4LRuCiSdLa1qxiYSodWEUVdbDRL waSjY6DZuU4XB3NuwYa7dIrTRRuWECRP0oQitNycO+QJgpfFQjDSnhhAQ56IEj6KBTYNDz vauCPuaTRvNaVDL2d7boo2qyf3qcCF/3Ll6NzXeResowOuWe2nffhCyPmbjn6p/eVf914y ZOJEphJWgDi9elU++/IMpOM0dLOh825b7FjPc8QCmYxPz0rU/C1PXVuSISU/1g== X-Rspamd-Queue-Id: 4J4gBb23g1znR Authentication-Results: mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=pass (policy=none) header.from=leo-andres.de X-Spamd-Result: default: False [-3.68 / 11.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-0.99)[-0.990]; SPF_REPUTATION_HAM(-0.88)[-0.88338842932253]; R_MISSING_CHARSET(0.50)[]; MX_INVALID(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[leo-andres.de,none]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; IP_REPUTATION_HAM(-0.01)[asn: 205766(0.00), country: DE(-0.01), ip: 185.26.156.147(0.00)]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; ARC_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_LAST(0.00)[] X-Rspamd-Server: mail01.haj.ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This implements a function to determine if Pakfire is already running. It tests the PID and lockfile and can be expanded easily later. 'pidof' checks the full path to avoid confusion. Removes the unreachable function "refreshpage". Signed-off-by: Leo-Andres Hofmann --- html/cgi-bin/pakfire.cgi | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi index 4d6eee284..7957bc154 100644 --- a/html/cgi-bin/pakfire.cgi +++ b/html/cgi-bin/pakfire.cgi @@ -44,8 +44,6 @@ $cgiparams{'VALID'} = ''; $cgiparams{'INSPAKS'} = ''; $cgiparams{'DELPAKS'} = ''; -sub refreshpage{&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'pagerefresh'}
";&Header::closebox();} - &Header::getcgihash(\%cgiparams); &General::readhash("${General::swroot}/main/settings", \%mainsettings); @@ -54,7 +52,7 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "" ); print < @@ -203,7 +197,6 @@ END &Header::closebigbox(); &Header::closepage(); exit; - refreshpage(); } my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`; @@ -314,3 +307,16 @@ END &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")); +} From patchwork Thu Dec 2 15:39:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 4891 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4J4gBs1C12z3wg9 for ; Thu, 2 Dec 2021 15:40:21 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4J4gBn46vQz3R2; Thu, 2 Dec 2021 15:40:17 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4J4gBn2kjhz30HL; Thu, 2 Dec 2021 15:40:17 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4J4gBm3bjgz2yfp for ; Thu, 2 Dec 2021 15:40:16 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4J4gBg1LWxz2f6 for ; Thu, 2 Dec 2021 15:40:11 +0000 (UTC) Received: (qmail 22068 invoked from network); 2 Dec 2021 15:40:06 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 2 Dec 2021 15:40:06 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH 2/4] pakfire.cgi: Implement JavaScript log message display Date: Thu, 2 Dec 2021 16:39:53 +0100 Message-Id: <20211202153955.1126-2-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20211202153955.1126-1-hofmann@leo-andres.de> References: <20211202153955.1126-1-hofmann@leo-andres.de> MIME-Version: 1.0 ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1638459611; a=rsa-sha256; cv=none; b=jqil0/upNfXczagIb+gQOp3Rbsu3fG7ONlDWzCTqvguqi3+9xskSAaktf3dAd9baxxKXUs Cjm7VBTTc5hSdCr/r7aX+/Iqsn47/n24cpZaTkHLdWiPN+6URm9ADMc22y1kT65Uhko/8u u2ystx4/jbDkoyb+Xb85fO2J/dux/OwL521ad5q8aCJ3zaSWd8xCwT7KGdtmI62NT8eeai 5gAuM/xbRYFv4VjRxpRrpzD1XWXVIK8btLhXEbBRFJRfy5kCnRQDJBFYCk6DlgVNiGJpOW 4yxA/gbpLBkGYI9RAlAK/ldPlBEAt9NGr90E3DINGnkzfOodor1BP0LFCSGBGg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=pass (policy=none) header.from=leo-andres.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1638459611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wm2Ef+dbhjZ4XQ/SUWB8l/fAgrfH8PkoT4WECJhupyI=; b=v7iA165fiVcxD8QHTSOzF0d/J61kyTJRuOIpnbeoRksnZ3Tnoifdwp292tlPzL2q13KOT8 XOzT86vUySY7IVi/v/U13MXQBGvib/MfwiphkjYN5yNvjW0P4vKqkmeqykMCQZnNbbCe/Q 1MvG8JUTgN7Bugx1ZxfiRy9k7U7QVCO1e9rVU+xYgNvvtUT1W/8an3LhoT5VG2n7kfjL9h gfkhj0DCityeJZPnmFk6AtBOF3/C/cBZjlfHSabvJFPapNE8dAZXjEPP9hLk6ya/Y6lYKM /e0d/kdvVbSe9I9+CQVaD5O6cOr7ac3neGbQzWyaoMMjQEhwX5N3iKR/ibOaAw== X-Rspamd-Queue-Id: 4J4gBg1LWxz2f6 Authentication-Results: mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=pass (policy=none) header.from=leo-andres.de X-Spamd-Result: default: False [-1.45 / 11.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_SPAM(0.94)[0.942]; SPF_REPUTATION_HAM(-0.88)[-0.88338842932253]; MX_INVALID(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[leo-andres.de,none]; R_MISSING_CHARSET(0.50)[]; R_SPF_ALLOW(-0.20)[+mx:c]; MIME_HTML_ONLY(0.20)[]; IP_REPUTATION_HAM(-0.01)[asn: 205766(0.00), country: DE(-0.01), ip: 185.26.156.147(0.00)]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:~]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; ARC_NA(0.00)[] X-Rspamd-Server: mail01.haj.ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Currently the page becomes unresponsive while Pakfire is busy. This patch implements a AJAX/JSON driven log output, to provide continuous information to the user while Pakfire is running. The output is updated 1x per second, if the load should be too high, the interval can be change by writing to "pakfire.refreshInterval". Signed-off-by: Leo-Andres Hofmann --- html/cgi-bin/pakfire.cgi | 153 ++++++++++++++++++---- html/html/include/pakfire.js | 241 +++++++++++++++++++++++++++++++++++ 2 files changed, 368 insertions(+), 26 deletions(-) create mode 100644 html/html/include/pakfire.js diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi index 7957bc154..e5f5f7d6a 100644 --- a/html/cgi-bin/pakfire.cgi +++ b/html/cgi-bin/pakfire.cgi @@ -36,8 +36,11 @@ my %color = (); my %pakfiresettings = (); my %mainsettings = (); -&Header::showhttpheaders(); +# Load general settings +&General::readhash("${General::swroot}/main/settings", \%mainsettings); +&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color); +# Get CGI request data $cgiparams{'ACTION'} = ''; $cgiparams{'VALID'} = ''; @@ -46,12 +49,102 @@ $cgiparams{'DELPAKS'} = ''; &Header::getcgihash(\%cgiparams); -&General::readhash("${General::swroot}/main/settings", \%mainsettings); -&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color); +### Process AJAX/JSON request ### +if($cgiparams{'ACTION'} eq 'json-getstatus') { + # Send HTTP headers + _start_json_output(); + + # Collect Pakfire status and log messages + my %status = ( + 'running' => &_is_pakfire_busy() || "0", + 'running_since' => &General::age("$Pakfire::lockfile") || "0s", + 'reboot' => (-e "/var/run/need_reboot") || "0" + ); + my @messages = `tac /var/log/messages | sed -n '/pakfire:/{p;/Pakfire.*started/q}'`; + + # Start JSON file + print "{\n"; + + foreach my $key (keys %status) { + my $value = $status{$key}; + print qq{\t"$key": "$value",\n}; + } + + # Print sanitized messages in reverse order to undo previous "tac" + print qq{\t"messages": [\n}; + for my $index (reverse (0 .. $#messages)) { + my $line = $messages[$index]; + $line =~ s/[[:cntrl:]<>&\\]+//g; + + print qq{\t\t"$line"}; + print ",\n" unless $index < 1; + } + print "\n\t]\n"; + + # Finalize JSON file & stop + print "}"; + exit; +} + +### Start pakfire page ### +&Header::showhttpheaders(); + +###--- HTML HEAD ---### +my $extraHead = < + /* Pakfire log viewer */ + section#pflog-header { + width: 100%; + display: flex; + text-align: left; + align-items: center; + column-gap: 20px; + } + #pflog-header > div:last-child { + margin-left: auto; + margin-right: 20px; + } + #pflog-header span { + line-height: 1.3em; + } + #pflog-header span:empty::before { + content: "\\200b"; /* zero width space */ + } + + pre#pflog-messages { + margin-top: 0.7em; + padding-top: 0.7em; + border-top: 0.5px solid $Header::bordercolour; -&Header::openpage($Lang::tr{'pakfire configuration'}, 1); + text-align: left; + min-height: 15em; + overflow-x: auto; + } + + + + +END +; +###--- END HTML HEAD ---### + +&Header::openpage($Lang::tr{'pakfire configuration'}, 1, $extraHead); &Header::openbigbox('100%', 'left', '', $errormessage); +# Process Pakfire commands if (($cgiparams{'ACTION'} eq 'install') && (! &_is_pakfire_busy())) { my @pkgs = split(/\|/, $cgiparams{'INSPAKS'}); if ("$cgiparams{'FORCE'}" eq "on") { @@ -170,29 +263,30 @@ if ($errormessage) { &Header::closebox(); } -# Check if pakfire is already running. -if (&_is_pakfire_busy()) { - &Header::openbox( 'Waiting', 1, "" ); - print < - - $Lang::tr{  - - $Lang::tr{'pakfire working'} - -
- -
- -END - my @output = `grep pakfire /var/log/messages | tail -20`; - foreach (@output) { - print "$_
"; - } - print < - +# Show log output while Pakfire is running +if(&_is_pakfire_busy()) { + &Header::openbox("100%", "center", "Pakfire"); + + print < +
$Lang::tr{'active'}
+
+ $Lang::tr{'pakfire working'}
+
+ +
+
$Lang::tr{'refresh'}
+ + + +

+
+
 END
+;
+
 	&Header::closebox();
 	&Header::closebigbox();
 	&Header::closepage();
@@ -320,3 +414,10 @@ sub _is_pakfire_busy {
 	# Test presence of PID or lockfile
 	return (($pakfire_pid) || (-e "$Pakfire::lockfile"));
 }
+
+# Send HTTP headers
+sub _start_json_output {
+	print "Cache-Control: no-cache, no-store\n";
+	print "Content-Type: application/json\n";
+	print "\n"; # End of HTTP headers
+}
diff --git a/html/html/include/pakfire.js b/html/html/include/pakfire.js
new file mode 100644
index 000000000..0950870e0
--- /dev/null
+++ b/html/html/include/pakfire.js
@@ -0,0 +1,241 @@
+/*#############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007-2021  IPFire Team                       #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see .       #
+#                                                                             #
+#############################################################################*/
+
+"use strict";
+
+// Pakfire Javascript functions (requires jQuery)
+class PakfireJS {
+	constructor() {
+		//--- Public properties ---
+		// Translation strings
+		this.i18n = new PakfireI18N();
+
+		//--- Private properties ---
+		// Status flags (access outside constructor only with setter/getter)
+		this._states = Object.create(null);
+		this._states.running = false;
+		this._states.reboot = false;
+
+		// Status refresh helper
+		this._autoRefresh = {
+			delay: 1000, //Delay between requests (default: 1s)
+			jsonAction: 'getstatus', //CGI POST action parameter
+			timeout: 5000, //XHR timeout (5s)
+
+			delayTimer: null, //setTimeout reference
+			jqXHR: undefined, //jQuery.ajax promise reference
+			get runningDelay() { //Waiting for end of delay
+				return (this.delayTimer !== null);
+			},
+			get runningXHR() { //Waiting for CGI response
+				return (this.jqXHR && (this.jqXHR.state() === 'pending'));
+			},
+			get isRunning() {
+				return (this.runningDelay || this.runningXHR);
+			}
+		};
+	}
+
+	//### Public properties ###
+
+	// Pakfire is running (true/false)
+	set running(state) {
+		if(this._states.running !== state) {
+			this._states.running = state;
+			this._states_onChange('running');
+		}
+	}
+	get running() {
+		return this._states.running;
+	}
+
+	// Reboot needed (true/false)
+	set reboot(state) {
+		if(this._states.reboot !== state) {
+			this._states.reboot = state;
+			this._states_onChange('reboot');
+		}
+	}
+	get reboot() {
+		return this._states.reboot;
+	}
+
+	// Status refresh interval in ms
+	set refreshInterval(delay) {
+		if(delay < 500) {
+			delay = 500; //enforce reasonable minimum
+		}
+		this._autoRefresh.delay = delay;
+	}
+	get refreshInterval() {
+		return this._autoRefresh.delay;
+	}
+
+	// Document loaded (call once from jQuery.ready)
+	documentReady() {
+		// Status refresh late start
+		if(this.running && (! this._autoRefresh.isRunning)) {
+			this._autoRefresh_runNow();
+		}
+	}
+
+	//### Private properties ###
+
+	// Pakfire status change handler
+	// property: Affected status (running, reboot, ...)
+	_states_onChange(property) {
+		// Always update UI
+		if(this.running) {
+			$('#pflog-status').text(this.i18n.get('working'));
+			$('#pflog-action').empty();
+		} else {
+			$('#pflog-status').text(this.i18n.get('finished'));
+			if(this.reboot) { //Enable return or reboot links in UI
+				$('#pflog-action').html(this.i18n.get('link_reboot'));
+			} else {
+				$('#pflog-action').html(this.i18n.get('link_return'));
+			}
+		}
+
+		// Start/stop status refresh if Pakfire started/stopped
+		if(property === 'running') {
+			if(this.running) {
+				this._autoRefresh_runNow();
+			} else {
+				this._autoRefresh_clearSchedule();
+			}
+		}
+	}
+
+	//--- Status refresh scheduling functions ---
+
+	// Immediately perform AJAX status refresh request
+	_autoRefresh_runNow() {
+		if(this._autoRefresh.runningXHR) {
+			return; // Don't send multiple requests
+		}
+		this._autoRefresh_clearSchedule(); // Stop scheduled refresh, will send immediately
+
+		// Send AJAX request, attach listeners
+		this._autoRefresh.jqXHR = this._JSON_get(this._autoRefresh.jsonAction, this._autoRefresh.timeout);
+		this._autoRefresh.jqXHR.done(function() { // Request succeeded
+			if(this.running) { // Keep refreshing while Pakfire is running
+				this._autoRefresh_scheduleRun();
+			}
+		});
+		this._autoRefresh.jqXHR.fail(function() { // Request failed
+			this._autoRefresh_scheduleRun(); // Try refreshing until valid status is received
+		});
+	}
+
+	// Schedule next refresh
+	_autoRefresh_scheduleRun() {
+		if(this._autoRefresh.runningDelay || this._autoRefresh.runningXHR) {
+			return; // Refresh already scheduled or in progress
+		}
+		this._autoRefresh.delayTimer = window.setTimeout(function() {
+			this._autoRefresh.delayTimer = null;
+			this._autoRefresh_runNow();
+		}.bind(this), this._autoRefresh.delay);
+	}
+
+	// Stop scheduled refresh (can still be refreshed up to 1x if XHR is already sent)
+	_autoRefresh_clearSchedule() {
+		if(this._autoRefresh.runningDelay) {
+			window.clearTimeout(this._autoRefresh.delayTimer);
+			this._autoRefresh.delayTimer = null;
+		}
+	}
+
+	//--- JSON request & data handling ---
+
+	// Load JSON data from Pakfire CGI, using a POST request
+	// action: POST paramter "json-[action]"
+	// maxTime: XHR timeout, 0 = no timeout
+	_JSON_get(action, maxTime = 0) {
+		return $.ajax({
+			url: '/cgi-bin/pakfire.cgi',
+			method: 'POST',
+			timeout: maxTime,
+			context: this,
+			data: {'ACTION': `json-${action}`},
+			dataType: 'json' //automatically check and convert result
+		})
+			.done(function(response) {
+				this._JSON_process(action, response);
+			});
+	}
+
+	// Process successful response from Pakfire CGI
+	// action: POST paramter "json-[action]" used to send request
+	// data: JSON data object
+	_JSON_process(action, data) {
+		// Pakfire status refresh
+		if(action === this._autoRefresh.jsonAction) {
+			// Update status flags
+			this.running = (data['running'] != '0');
+			this.reboot = (data['reboot'] != '0');
+
+			// Update timer display
+			if(this.running && data['running_since']) {
+				$('#pflog-time').text(this.i18n.get('since') + data['running_since']);
+			} else {
+				$('#pflog-time').empty();
+			}
+
+			// Print log messages
+			let messages = "";
+			data['messages'].forEach(function(line) {
+				messages += `${line}\n`;
+			});
+			$('#pflog-messages').text(messages);
+		}
+	}
+}
+
+// Simple translation strings helper
+// Format: {key: "translation"}
+class PakfireI18N {
+	constructor() {
+		this._strings = Object.create(null); //Object without prototypes
+	}
+
+	// Get translation
+	get(key) {
+		if(Object.prototype.hasOwnProperty.call(this._strings, key)) {
+			return this._strings[key];
+		}
+		return `(undefined string '${key}')`;
+	}
+
+	// Load key/translation object
+	load(translations) {
+		if(translations instanceof Object) {
+			Object.assign(this._strings, translations);
+		}
+	}
+}
+
+//### Initialize Pakfire ###
+const pakfire = new PakfireJS();
+
+$(function() {
+	pakfire.documentReady();
+});

From patchwork Thu Dec  2 15:39:54 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Patchwork-Submitter: Leo-Andres Hofmann 
X-Patchwork-Id: 4889
Return-Path: 
Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384)
	 client-signature ECDSA (P-384))
	(Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK))
	by web04.haj.ipfire.org (Postfix) with ESMTPS id 4J4gBq1pYkz3wtP
	for ; Thu,  2 Dec 2021 15:40:19 +0000 (UTC)
Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384)
	 client-signature ECDSA (P-384))
	(Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK))
	by mail01.ipfire.org (Postfix) with ESMTPS id 4J4gBm3ZYGz3Zh;
	Thu,  2 Dec 2021 15:40:16 +0000 (UTC)
Received: from mail02.haj.ipfire.org (localhost [127.0.0.1])
	by mail02.haj.ipfire.org (Postfix) with ESMTP id 4J4gBm3BQKz2yW0;
	Thu,  2 Dec 2021 15:40:16 +0000 (UTC)
Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-384)
 client-signature ECDSA (P-384))
 (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK))
 by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4J4gBk4PMvz2xXd
 for ; Thu,  2 Dec 2021 15:40:14 +0000 (UTC)
Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147])
 (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mail01.ipfire.org (Postfix) with ESMTPS id 4J4gBd3C5Vz1WS
 for ; Thu,  2 Dec 2021 15:40:09 +0000 (UTC)
Received: (qmail 22134 invoked from network); 2 Dec 2021 15:40:06 -0000
Received: from localhost (HELO localhost) (127.0.0.1)
 by arche.uberspace.de with SMTP; 2 Dec 2021 15:40:06 -0000
From: Leo-Andres Hofmann 
To: development@lists.ipfire.org
Subject: [PATCH 3/4] pakfire.cgi: Add new translations
Date: Thu,  2 Dec 2021 16:39:54 +0100
Message-Id: <20211202153955.1126-3-hofmann@leo-andres.de>
X-Mailer: git-send-email 2.27.0.windows.1
In-Reply-To: <20211202153955.1126-1-hofmann@leo-andres.de>
References: <20211202153955.1126-1-hofmann@leo-andres.de>
MIME-Version: 1.0
ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1638459609; a=rsa-sha256;
 cv=none;
 b=o1zcdNSGu7bDbCamAyy1nSpxzoCUdMf2RNyX5pmnvIrVQxTvaS934EafhqVU7GlnRR5ikL
 CBDU90Cm/6xD7tN1HWwGteiKsoZ5pnvNLHhZPpXTRSDfz6+TuYC9YJLOFMAEx6XaRjWnag
 S0napP0h1k2OMGxVHHVf3TIwqg/xqqvfuKgdW1wFB91sixQd/F2WdMB64Y2GWziHFF5IYP
 KFZ/6UF5P2HaYcwQ5IRT6JmTeRJfgfmE/e6nPu3tcowFRwEV8zegqFJNg6pATawqr2OL5g
 CCr+vQBA/I6CzJXVK/mCTuHpmm+V+4FGhglKpC4SuN7MTtY/ygVEFVsIqtD8KA==
ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none;
 spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates
 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de;
 dmarc=pass (policy=none) header.from=leo-andres.de
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
 d=lists.ipfire.org;
 s=202003rsa; t=1638459609;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=UZvSWlmzkaSl9pUSGI8q4v4CVdz2tGaoJ2xu4QjjEVM=;
 b=p4w4jnyFTWhrsFTckXzEify20O9sBK6+3siiqgqkrv0PuSHS2WOWmLNbhHCVATGfe12JFT
 zRCMv1LcYnGoXpCK3EIT8TM2RDF6p3/4/XLpdjwiuTI9BCKzDEi8dI8oSiX+MnOo6aYNSs
 HWCSskiFY7y2TlzRxY2kBOduTICdw/TuuRUNWXCZAYgRy0mPCvCfZvvKYGgyx6p3blzP3O
 zf+Z7LDEx9bSO3Cfnj/hTHyaQxgQkqgRAcUTl+KEriHJpFSYGkUtIfGeRybUzJTBmOM6LJ
 FOZzRYXAVJBS2aOTScUt6WJNifPa0+MFUFF0fIHhGdCxj94e375mUYZUX0nRdQ==
X-Rspamd-Queue-Id: 4J4gBd3C5Vz1WS
Authentication-Results: mail01.ipfire.org; dkim=none;
 spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates
 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de;
 dmarc=pass (policy=none) header.from=leo-andres.de
X-Spamd-Result: default: False [-4.14 / 11.00]; BAYES_HAM(-3.00)[99.99%];
 MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-0.95)[-0.953];
 SPF_REPUTATION_HAM(-0.88)[-0.88338842932253];
 DMARC_POLICY_ALLOW(-0.50)[leo-andres.de,none];
 MX_INVALID(0.50)[]; R_SPF_ALLOW(-0.20)[+mx:c];
 MIME_GOOD(-0.10)[text/plain];
 IP_REPUTATION_HAM(-0.01)[asn: 205766(0.00), country: DE(-0.01), ip:
 185.26.156.147(0.00)];
 ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE];
 FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[];
 MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[];
 RCPT_COUNT_ONE(0.00)[1]; FROM_HAS_DN(0.00)[];
 RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[];
 ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1];
 TO_DN_NONE(0.00)[]; ARC_NA(0.00)[]
X-Rspamd-Server: mail01.haj.ipfire.org
X-BeenThere: development@lists.ipfire.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: IPFire development talk 
List-Unsubscribe: ,
 
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
 
Errors-To: development-bounces@lists.ipfire.org
Sender: "Development" 

Signed-off-by: Leo-Andres Hofmann 
---
 html/cgi-bin/pakfire.cgi | 4 ++--
 langs/de/cgi-bin/de.pl   | 2 ++
 langs/en/cgi-bin/en.pl   | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi
index e5f5f7d6a..72518a6fe 100644
--- a/html/cgi-bin/pakfire.cgi
+++ b/html/cgi-bin/pakfire.cgi
@@ -127,10 +127,10 @@ my $extraHead = <Return to Pakfire',
+		'link_return': '$Lang::tr{'pakfire return'}',
 		'link_reboot': '$Lang::tr{'needreboot'}'
 	});
 	
diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl
index c81b28fea..490879c90 100644
--- a/langs/de/cgi-bin/de.pl
+++ b/langs/de/cgi-bin/de.pl
@@ -1974,6 +1974,7 @@
 'pakfire configuration' => 'Pakfire Konfiguration',
 'pakfire core update auto' => 'Core- und Addon-Updates automatisch installieren:',
 'pakfire core update level' => 'Core-Update-Level',
+'pakfire finished' => 'Pakfire ist fertig!. Bitte überprüfen Sie die Log Ausgabe.',
 'pakfire health check' => 'Mirrors auf Erreichbarkeit prüfen (Ping):',
 'pakfire install description' => 'Wählen Sie ein oder mehrere Pakete zur Installation aus und drücken Sie auf das plus-Symbol.',
 'pakfire install package' => 'Sie möchten folgende Pakete installieren: ',
@@ -1985,6 +1986,7 @@
 'pakfire last update' => 'Letztes Update ist',
 'pakfire possible dependency' => ' Möglicherweise haben diese Pakete Abhängigkeiten, d.h. andere Pakete müssen zusätzlich installiert werden. Dazu sehen Sie unten eine Liste.',
 'pakfire register' => 'Registrierung am Pakfire-Server:',
+'pakfire return' => 'Zurück zu Pakfire',
 'pakfire system state' => 'System Status',
 'pakfire tree' => 'Zu verwendendes Pakfire-Repository:',
 'pakfire tree stable' => 'Veröffentlichte Versionen (stable)',
diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl
index a92bb07f8..4442ea772 100644
--- a/langs/en/cgi-bin/en.pl
+++ b/langs/en/cgi-bin/en.pl
@@ -2009,6 +2009,7 @@
 'pakfire configuration' => 'Pakfire Configuration',
 'pakfire core update auto' => 'Install core and addon updates automatically:',
 'pakfire core update level' => 'Core-Update-Level',
+'pakfire finished' => 'Pakfire is finished! Please check the log output.',
 'pakfire health check' => 'Check if mirror is reachable (ping):',
 'pakfire install description' => 'Please choose one or more items from the list below and click the plus to install.',
 'pakfire install package' => 'You want to install the following packages: ',
@@ -2020,6 +2021,7 @@
 'pakfire last update' => 'Last update made',
 'pakfire possible dependency' => ' There may be depending packages, here is a list of packages that need to be installed.',
 'pakfire register' => 'Register at pakfire-server:',
+'pakfire return' => 'Return to Pakfire',
 'pakfire system state' => 'System Status',
 'pakfire tree' => 'Repository',
 'pakfire tree stable' => 'Stable',

From patchwork Thu Dec  2 15:39:55 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Leo-Andres Hofmann 
X-Patchwork-Id: 4890
Return-Path: 
Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384)
	 client-signature ECDSA (P-384))
	(Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK))
	by web04.haj.ipfire.org (Postfix) with ESMTPS id 4J4gBr2PQHz3wtT
	for ; Thu,  2 Dec 2021 15:40:20 +0000 (UTC)
Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384)
	 client-signature ECDSA (P-384))
	(Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK))
	by mail01.ipfire.org (Postfix) with ESMTPS id 4J4gBm55tMz3Ny;
	Thu,  2 Dec 2021 15:40:16 +0000 (UTC)
Received: from mail02.haj.ipfire.org (localhost [127.0.0.1])
	by mail02.haj.ipfire.org (Postfix) with ESMTP id 4J4gBm43Kvz300y;
	Thu,  2 Dec 2021 15:40:16 +0000 (UTC)
Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature ECDSA (P-384)
 client-signature ECDSA (P-384))
 (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK))
 by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4J4gBl0Cpcz2xXd
 for ; Thu,  2 Dec 2021 15:40:15 +0000 (UTC)
Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147])
 (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mail01.ipfire.org (Postfix) with ESMTPS id 4J4gBd6Jz5z2cF
 for ; Thu,  2 Dec 2021 15:40:09 +0000 (UTC)
Received: (qmail 22140 invoked from network); 2 Dec 2021 15:40:07 -0000
Received: from localhost (HELO localhost) (127.0.0.1)
 by arche.uberspace.de with SMTP; 2 Dec 2021 15:40:07 -0000
From: Leo-Andres Hofmann 
To: development@lists.ipfire.org
Subject: [PATCH 4/4] pakfire.cgi: Remove "sleep" after running Pakfire command
Date: Thu,  2 Dec 2021 16:39:55 +0100
Message-Id: <20211202153955.1126-4-hofmann@leo-andres.de>
X-Mailer: git-send-email 2.27.0.windows.1
In-Reply-To: <20211202153955.1126-1-hofmann@leo-andres.de>
References: <20211202153955.1126-1-hofmann@leo-andres.de>
MIME-Version: 1.0
ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1638459609; a=rsa-sha256;
 cv=none;
 b=Q6Q9vaZrpg4+0kt/DEbcifTMexVmDNMLv7SZaNtJJaSUehGU3XLo6NB37BHzUAaD8Fb2qb
 Gppg1nF2FM/qNcyTXk4V3lTp46W5Gl24ydrKiBvVPrYozmTQdyRB+jLjzO1F/QWqsFCP8v
 mHMGPurv0QW4hyJ1yvUZW6kdBbdRvOdBkT2rGqddd84M5mnkUEEg/6hQiOgrNsmWGW4L++
 m9JD5nSiGW1YBwk4LpKW+QDXezu8OtuNxPVDdrRl9kg7yovBUVeQnUyCG3EBwvh2wAUG4V
 Rz6wyYoiSOyTpeW2Ufb75VGbdCZhq6ToXUKBYiqknSBZGpxjQhZ1ogu1UcCPUQ==
ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none;
 spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates
 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de;
 dmarc=pass (policy=none) header.from=leo-andres.de
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
 d=lists.ipfire.org;
 s=202003rsa; t=1638459609;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=55vjlCaQY3aKXPt/i2J84/y/Pekpawj9iuBeyfEiLw4=;
 b=FcvxYWpT32y94Hg2bpB/RDm76dW5o44E2HLzX42FOITfOkIaCYm1tsv4dvfIDXBlKWSGIl
 8/0SpvbvH+EciDZAuGaE0VNXPzHhC/SSLzXhCp6ef6Og2zROVu6pVw1sH69aHVL5rFgT2A
 YmrmZh+/cktADP5F0phrFRGaIanwSSCjE3sENEG7GpJnFz7WptGxsDQ0A3bMDLHSdW7C02
 /HmN348B01YicyVHwSLrrR1U67kJrN6XMo6FuFSfqImHErq2DTFVeh3GDbvNUhEd9ZsJA4
 LeD1ZCs/b5Uh2G+nAwqhEKtdaP7qCbF5wCfvplD0eouKlblp1SLy1d7boypHTg==
X-Rspamd-Queue-Id: 4J4gBd6Jz5z2cF
Authentication-Results: mail01.ipfire.org; dkim=none;
 spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates
 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de;
 dmarc=pass (policy=none) header.from=leo-andres.de
X-Spamd-Result: default: False [-3.68 / 11.00]; BAYES_HAM(-3.00)[99.99%];
 MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-0.99)[-0.991];
 SPF_REPUTATION_HAM(-0.88)[-0.88338842932253];
 R_MISSING_CHARSET(0.50)[]; MX_INVALID(0.50)[];
 DMARC_POLICY_ALLOW(-0.50)[leo-andres.de,none];
 R_SPF_ALLOW(-0.20)[+mx:c]; MIME_GOOD(-0.10)[text/plain];
 IP_REPUTATION_HAM(-0.01)[asn: 205766(0.00), country: DE(-0.01), ip:
 185.26.156.147(0.00)]; MIME_TRACE(0.00)[0:+];
 R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[];
 ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE];
 RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_TWO(0.00)[2];
 FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[];
 TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1];
 ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1];
 ARC_NA(0.00)[]
X-Rspamd-Server: mail01.haj.ipfire.org
X-BeenThere: development@lists.ipfire.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: IPFire development talk 
List-Unsubscribe: ,
 
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
 
Errors-To: development-bounces@lists.ipfire.org
Sender: "Development" 

The extended lockfile test seems to be sufficient to detect
a running Pakfire process and display the logs.
"Sleep" even proved to be counterproductive, as fast processes
can finish in under a second and are then again not detected.

Signed-off-by: Leo-Andres Hofmann 
---
 html/cgi-bin/pakfire.cgi | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi
index 72518a6fe..e14658ffb 100644
--- a/html/cgi-bin/pakfire.cgi
+++ b/html/cgi-bin/pakfire.cgi
@@ -149,7 +149,6 @@ 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);
-		sleep(1);
 	} else {
 		&Header::openbox("100%", "center", $Lang::tr{'request'});
 		my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", @pkgs);
@@ -187,7 +186,6 @@ END
 	my @pkgs = split(/\|/, $cgiparams{'DELPAKS'});
 	if ("$cgiparams{'FORCE'}" eq "on") {
 		&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);
@@ -224,10 +222,8 @@ END
 
 } 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') && (! &_is_pakfire_busy())) {
 	&General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors");
-	sleep(1);
 } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
 	$pakfiresettings{"TREE"} = $cgiparams{"TREE"};
 
@@ -241,7 +237,6 @@ END
 
 		# Update lists
 		&General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors");
-		sleep(1);
 	}
 }