From patchwork Fri Apr 23 16:15:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 4210 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 4FRfYX5tfRz44R4 for ; Fri, 23 Apr 2021 16:16:32 +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 4FRfYX2pR6z2cD; Fri, 23 Apr 2021 16:16:32 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4FRfYX2135z2y0r; Fri, 23 Apr 2021 16:16:32 +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 4FRfYW3Pztz2xLb for ; Fri, 23 Apr 2021 16:16:31 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (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 4FRfYS5nv0z5Z for ; Fri, 23 Apr 2021 16:16:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 3786253032 for ; Fri, 23 Apr 2021 18:16:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sXMK8mpg211u for ; Fri, 23 Apr 2021 18:16:26 +0200 (CEST) Received: from amaterasu.sicho.home ([192.168.0.1] helo=chojin.sicho.home) by filekeeper.sicho.home with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1lZyTH-0007uY-8q; Fri, 23 Apr 2021 18:15:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1619194581; bh=DxADJthE0ozXEYEdyjLxtZ6JjrjmypICDMDQDYu7pI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=f4D2f2FSe5lr+KxDSjd3ES8PrLOuSZroPqOZ3coRinn1fvUFDuD8a5BSCjqc0beep o+itTEobv2FA3gMXDrK4epHLO9cyVTmbxmRVlq6ubI454LYSD+HcNLskKmxMthEXGb ReU0+FvcRnMt1SeQrTIFg1Sr5mKBgqJCXe/R+uubnGWSdGs1EG6u3TMc8XD4y7nMXI R8+7+Gs8F/+whkhgDxwu2B64KscpyDk+9d47XYQlsPXtNCEvZOsv0XvMkqo6zCq97y IeeGXONBaS5tDPTi6js55Hpy/cSo13u4B2bP0q7MBzWH+hUXEx2w8J6Y5bWCeuviUY 8g2yY/hrq995A== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH 3/3] services.cgi: use new Pakfire::pakinfo function Date: Fri, 23 Apr 2021 18:15:34 +0200 Message-Id: <20210423161534.32738-4-robin.roevens@disroot.org> In-Reply-To: <20210423161534.32738-1-robin.roevens@disroot.org> References: <20210423161534.32738-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-filekeeper-MailScanner-ID: 1lZyTH-0007uY-8q X-filekeeper-MailScanner: Found to be clean X-filekeeper-MailScanner-From: robin.roevens@disroot.org X-filekeeper-MailScanner-Watermark: 1619799373.16979@bV0BR/XuRpbzMGaMmpEX8Q ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1619194588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=atky2w0Td7Gv8HkD8tzbrBrPav9e2RhP1QTYO8x762A=; b=UMbogUqRzm9nRO/xdMvdZ/66zF2yQ0ajl+QVEynEV1zcJYDoKRsMUJW1uwQnGXpQNaPVWP UmBpeZ+S9sfDloiwyWW6FWbMVegm5YHMCM5mdpoPhR7RQZoJpCOJpHknlcgVpvFi4nB0h1 lEKGD6F+VqX2SOuALGQCgkSK0oko0X+waoQeK+09rYcbo1IDdKm57QzIpfui6g5Q422Ew6 v+1HM4Z6Fb1MQ3sU8lytehOGtsHA16dLZPRiZqHwElCV8voydLJKMbEXdePgYVddyLZsd1 DK0nX9rt7y/G1MLxLG0um7Fwj0FA9cBGjKI3Dn2R4iOsmGhLUFdUv8yRlwNmsA== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=f4D2f2FS; dmarc=pass (policy=quarantine) header.from=disroot.org; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1619194588; a=rsa-sha256; cv=none; b=hXiVBKYMyMrmsK0QfPw8oDSUspfRkEJYDCPHl1y1SFMIeH0EeuejpG/MYOfM40Cf8oTvlZ 8ZNGjYzlwMy1sEGJcr0hUeBlyZHPRBaFR54hbFHCH7Piiw12XIfREEJe1si9ReOYHLGpgT gLnkoXoRgQX98PiBxZV8R0BbJaq0QhUd5R0puGFy6mHdYx1tPyxu77pzAimaCho6MWZFck 0cofyEq/GiPUUjahfciKmXcVRMOJZvHm1N0EeT4SJoE8tW7aCEbv/8rgQoBE6wSzoZLLUg ylajWaP61hByhnPUHe5i41VGOJZB7lP+uvpWCyb8HJH8ypUkTWCIVKr01ZPsdg== X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-2.20 / 11.00]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:c]; MV_CASE(0.50)[]; R_MISSING_CHARSET(2.50)[]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; IP_REPUTATION_HAM(-2.40)[asn: 50673(-0.34), country: NL(-0.01), ip: 178.21.23.139(-0.85)]; RCVD_COUNT_THREE(0.00)[4]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; DKIM_TRACE(0.00)[disroot.org:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:~]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; BAYES_HAM(-0.10)[65.65%]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[disroot.org:s=mail]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; HTML_SHORT_LINK_IMG_3(0.50)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; BLOCKLISTDE_FAIL(0.00)[178.21.23.139:server fail]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; MIME_HTML_ONLY(0.20)[] X-Rspamd-Queue-Id: 4FRfYS5nv0z5Z Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=f4D2f2FS; dmarc=pass (policy=quarantine) header.from=disroot.org; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.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" X-Spam: Yes Use new Pakfire::pakinfo function to determine installed addons and related services/initscripts more reliable. Signed-off-by: Robin Roevens --- html/cgi-bin/services.cgi | 96 ++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 37 deletions(-) diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index 38b89ef1e..66b0d711f 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -29,6 +29,7 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; require "${General::swroot}/graphs.pl"; +require "/opt/pakfire/lib/functions.pl"; my %color = (); my %mainsettings = (); @@ -160,48 +161,69 @@ END my $lines=0; # Used to count the outputlines to make different bgcolor - # Generate list of installed addon pak's - opendir (DIR, "/opt/pakfire/db/installed") || die "Cannot opendir /opt/pakfire/db/installed/: $!"; - my @pak = sort readdir DIR; - foreach (@pak){ - chomp($_); - next unless (m/^meta-/); - s/^meta-//; - - # Check which of the paks are services - if (-e "/etc/init.d/$_") { - # blacklist some packages - # - # alsa has trouble with the volume saving and was not really stopped - # mdadm should not stopped with webif because this could crash the system - # - if ( $_ eq 'squid' ) { - next; - } - if ( ($_ ne "alsa") && ($_ ne "mdadm") ) { - $lines++; - if ($lines % 2){ - print ""; - $col="bgcolor='$color{'color22'}'"; - }else{ - print ""; - $col="bgcolor='$color{'color20'}'"; + my ($paklist, $pakinfo); + my (@templine, @templine2); + my ($listline, $infoline); + my @paks; + my @addon_services; + + # Generate list of installed addon pak services + $Pakfire::enable_colors = 0; + open OUT, '>', \$paklist; + select OUT; + eval { \&Pakfire::dblist("installed", "noweb"); }; + select STDOUT; + + foreach $listline (split(/^/, "$paklist")) { + chomp($listline); + @templine = split(/\: /, $listline); + + if ("@templine[0]" eq "Name") { + open OUT, '>', \$pakinfo; + select OUT; + eval { \&Pakfire::pakinfo("@templine[1]", "installed"); }; + select STDOUT; + + foreach $infoline (split(/^/, $pakinfo)) { + chomp($infoline); + @templine2 = split(/\: /, $infoline); + + if ("@templine2[0]" eq "InitScripts" && "@templine2[1]") { + push(@addon_services, split(" ", "@templine2[1]")); } - print "$_ "; - my $status = isautorun($_,$col); - print "$status "; - print "$Lang::tr{"; - print "$Lang::tr{ "; - my $status = &isrunningaddon($_,$col); - $status =~ s/\\[[0-1]\;[0-9]+m//g; - - chomp($status); - print "$status"; - print ""; } } } + foreach (@addon_services) { + $lines++; + if ($lines % 2){ + print ""; + $col="bgcolor='$color{'color22'}'"; + }else{ + print ""; + $col="bgcolor='$color{'color20'}'"; + } + print "$_ "; + my $status = isautorun($_,$col); + print "$status "; + # Don't allow user to start/stop folowing services from webui: + # - alsa has trouble with the volume saving and was not really stopped + if ($_ eq "alsa") { + print ""; + print " "; + } else { + print "$Lang::tr{"; + print "$Lang::tr{ "; + } + my $status = &isrunningaddon($_,$col); + $status =~ s/\\[[0-1]\;[0-9]+m//g; + + chomp($status); + print "$status"; + print ""; + } + print "\n"; &Header::closebox();