mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
pakfire: Replace getmetadata duplicate code
- Use getmetadata function in services.cgi to determine installed
addon services to display. Removing code duplication and intel that
should only be known by pakfire itself.
- Removed hardcoded exclusions:
- squid should show up correctly using the new metadata info
- mdadm is part of core and will never show up here
- alsa, unknown if this problem still exists, but if it is, this
should be handled somewhere else.
Signed-off-by: Robin Roevens <robin.roevens@disroot.org>
This commit is contained in:
committed by
Peter Müller
parent
2be67e3841
commit
5cc18f9c12
@@ -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,51 +161,44 @@ 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;
|
||||
closedir(DIR);
|
||||
my @paks;
|
||||
my @addon_services;
|
||||
|
||||
foreach (@pak){
|
||||
chomp($_);
|
||||
next unless (m/^meta-/);
|
||||
s/^meta-//;
|
||||
# Generate list of installed addon pak services
|
||||
my %paklist = &Pakfire::dblist("installed");
|
||||
|
||||
# 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'}'";
|
||||
}
|
||||
|
||||
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 my $pak (keys %paklist) {
|
||||
my %metadata = &Pakfire::getmetadata($pak, "installed");
|
||||
|
||||
if ("$metadata{'Services'}") {
|
||||
foreach my $service (split(/ /, "$metadata{'Services'}")) {
|
||||
push(@addon_services, $service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 ";
|
||||
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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user