Use new Pakfire::pakinfo function to determine installed addons and related services/initscripts more reliable.
Signed-off-by: Robin Roevens robin.roevens@disroot.org --- 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 "<tr>"; - $col="bgcolor='$color{'color22'}'"; - }else{ - print "<tr>"; - $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 "<td align='left' $col width='31%'>$_</td> "; - my $status = isautorun($_,$col); - print "$status "; - print "<td align='center' $col width='8%'><a href='services.cgi?$_!start'><img alt='$Lang::tr{'start'}' title='$Lang::tr{'start'}' src='/images/go-up.png' border='0' /></a></td>"; - print "<td align='center' $col width='8%'><a href='services.cgi?$_!stop'><img alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' border='0' /></a></td> "; - my $status = &isrunningaddon($_,$col); - $status =~ s/\[[0-1];[0-9]+m//g; - - chomp($status); - print "$status"; - print "</tr>"; } } }
+ foreach (@addon_services) { + $lines++; + if ($lines % 2){ + print "<tr>"; + $col="bgcolor='$color{'color22'}'"; + }else{ + print "<tr>"; + $col="bgcolor='$color{'color20'}'"; + } + print "<td align='left' $col width='31%'>$_</td> "; + 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 "<td align='center' $col width='8%'></td>"; + print "<td align='center' $col width='8%'></td> "; + } else { + print "<td align='center' $col width='8%'><a href='services.cgi?$_!start'><img alt='$Lang::tr{'start'}' title='$Lang::tr{'start'}' src='/images/go-up.png' border='0' /></a></td>"; + print "<td align='center' $col width='8%'><a href='services.cgi?$_!stop'><img alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' border='0' /></a></td> "; + } + my $status = &isrunningaddon($_,$col); + $status =~ s/\[[0-1];[0-9]+m//g; + + chomp($status); + print "$status"; + print "</tr>"; + } + print "</table></div>\n"; &Header::closebox();