Hi all
While working on bugfix for 12935, I came accros a few things in services.cgi that started bothering me. But as those don't really have to do anything with bug, I added them as a seperate patchset. This patchset depends on the "Fix Bug#12935" patchset I posted earlier.
Regards Robin
* Singular 'Service' instead of plural 'Services' as column header of services table * Sort list of services
Signed-off-by: Robin Roevens robin.roevens@disroot.org --- html/cgi-bin/services.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index e91da884b..d480088a8 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -105,7 +105,7 @@ if ( $querry[0] =~ "processescpu"){ <div align='center'> <table width='80%' cellspacing='1' class='tbl'> <tr> - <th align='left'><b>$Lang::tr{'services'}</b></th> + <th align='left'><b>$Lang::tr{'service'}</b></th> <th align='center' ><b>$Lang::tr{'status'}</b></th> <th align='center'><b>PID</b></th> <th align='center'><b>$Lang::tr{'memory'}</b></th> @@ -167,7 +167,7 @@ END # Generate list of installed addon pak services my %paklist = &Pakfire::dblist("installed");
- foreach my $pak (keys %paklist) { + foreach my $pak (sort keys %paklist) { my %metadata = &Pakfire::getmetadata($pak, "installed"); my $service;
Reviewed-by: Bernhard Bitsch bbitsch@ipfire.org
Am 03.10.2022 um 17:39 schrieb Robin Roevens:
- Singular 'Service' instead of plural 'Services' as column header of services table
- Sort list of services
Signed-off-by: Robin Roevens robin.roevens@disroot.org
html/cgi-bin/services.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index e91da884b..d480088a8 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -105,7 +105,7 @@ if ( $querry[0] =~ "processescpu"){
<div align='center'> <table width='80%' cellspacing='1' class='tbl'> <tr> - <th align='left'><b>$Lang::tr{'services'}</b></th> + <th align='left'><b>$Lang::tr{'service'}</b></th> <th align='center' ><b>$Lang::tr{'status'}</b></th> <th align='center'><b>PID</b></th> <th align='center'><b>$Lang::tr{'memory'}</b></th> @@ -167,7 +167,7 @@ END # Generate list of installed addon pak services my %paklist = &Pakfire::dblist("installed");
- foreach my $pak (keys %paklist) {
- foreach my $pak (sort keys %paklist) { my %metadata = &Pakfire::getmetadata($pak, "installed"); my $service;
* Add restart action to services. * Only display available actions for a service: Start when service is stopped or Stop and Restart when a service is running.
Signed-off-by: Robin Roevens robin.roevens@disroot.org --- html/cgi-bin/services.cgi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index d480088a8..498d7fd8e 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -189,8 +189,6 @@ END
my $status = isautorun($pak,$service,$col); print "$status "; - print "<td align='center' $col width='8%'><a href='services.cgi?$pak!start!$service'><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?$pak!stop!$service'><img alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' border='0' /></a></td> "; my $status = isrunningaddon($pak,$service,$col); $status =~ s/\[[0-1];[0-9]+m//g;
@@ -300,7 +298,9 @@ sub isrunningaddon (@) { my $testcmd = @testcmd[0];
if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){ - $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>"; + $status = "<td align='center' $col width='8%'><a href='services.cgi?$pak!stop!$service'><img alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' border='0' /></a></td> "; + $status .= "<td align='center' $col width='8%'><a href='services.cgi?$pak!restart!$service'><img alt='$Lang::tr{'restart'}' title='$Lang::tr{'restart'}' src='/images/reload.gif' border='0' /></a></td> "; + $status .= "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>"; $testcmd =~ s/.* //gi; $testcmd =~ s/[a-z_]//gi; $testcmd =~ s/[[0-1];[0-9]+//gi; @@ -323,7 +323,8 @@ sub isrunningaddon (@) { } $status .="<td align='center' $col>$memory KB</td>"; }else{ - $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td><td colspan='2' $col></td>"; + $status = "<td align='center' $col width='16%' colspan=2><a href='services.cgi?$pak!start!$service'><img alt='$Lang::tr{'start'}' title='$Lang::tr{'start'}' src='/images/go-up.png' border='0' /></a></td>"; + $status .= "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td><td colspan='2' $col></td>"; } return $status; }
Reviewed-by: Bernhard Bitsch bbitsch@ipfire.org
Am 03.10.2022 um 17:39 schrieb Robin Roevens:
- Add restart action to services.
- Only display available actions for a service: Start when service is stopped or Stop and Restart when a service is running.
Signed-off-by: Robin Roevens robin.roevens@disroot.org
html/cgi-bin/services.cgi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index d480088a8..498d7fd8e 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -189,8 +189,6 @@ END
my $status = isautorun($pak,$service,$col); print "$status ";
print "<td align='center' $col width='8%'><a href='services.cgi?$pak!start!$service'><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?$pak!stop!$service'><img alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' border='0' /></a></td> "; my $status = isrunningaddon($pak,$service,$col); $status =~ s/\\[[0-1]\;[0-9]+m//g;
@@ -300,7 +298,9 @@ sub isrunningaddon (@) { my $testcmd = @testcmd[0];
if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){
$status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
$status = "<td align='center' $col width='8%'><a href='services.cgi?$pak!stop!$service'><img alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' border='0' /></a></td> ";
$status .= "<td align='center' $col width='8%'><a href='services.cgi?$pak!restart!$service'><img alt='$Lang::tr{'restart'}' title='$Lang::tr{'restart'}' src='/images/reload.gif' border='0' /></a></td> ";
$testcmd =~ s/.* //gi; $testcmd =~ s/[a-z_]//gi; $testcmd =~ s/[[0-1];[0-9]+//gi;$status .= "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
@@ -323,7 +323,8 @@ sub isrunningaddon (@) { } $status .="<td align='center' $col>$memory KB</td>"; }else{
$status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td><td colspan='2' $col></td>";
$status = "<td align='center' $col width='16%' colspan=2><a href='services.cgi?$pak!start!$service'><img alt='$Lang::tr{'start'}' title='$Lang::tr{'start'}' src='/images/go-up.png' border='0' /></a></td>";
} return $status; }$status .= "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td><td colspan='2' $col></td>";
* If a cgi file exists with the same name as an addon, the displayed service will be a link to that cgi file.
Signed-off-by: Robin Roevens robin.roevens@disroot.org --- html/cgi-bin/services.cgi | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index 498d7fd8e..d988b29a5 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -185,6 +185,10 @@ END
# Add addon name to displayname of service if servicename differs from addon my $displayname = ($pak ne $service) ? "$service ($pak)" : $service; + if ( -e "/srv/web/ipfire/cgi-bin/$pak.cgi" ) { + $displayname = ($pak ne $service) ? "$service (<a href='$pak.cgi'>$pak</a>)" : "<a href='$pak.cgi'>$service</a>"; + } + print "<td align='left' $col width='31%'>$displayname</td> ";
my $status = isautorun($pak,$service,$col);
Reviewed-by: Bernhard Bitsch bbitsch@ipfire.org
Am 03.10.2022 um 17:39 schrieb Robin Roevens:
- If a cgi file exists with the same name as an addon, the displayed service will be a link to that cgi file.
Signed-off-by: Robin Roevens robin.roevens@disroot.org
html/cgi-bin/services.cgi | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index 498d7fd8e..d988b29a5 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -185,6 +185,10 @@ END
# Add addon name to displayname of service if servicename differs from addon my $displayname = ($pak ne $service) ? "$service ($pak)" : $service;
if ( -e "/srv/web/ipfire/cgi-bin/$pak.cgi" ) {
$displayname = ($pak ne $service) ? "$service (<a href=\'$pak.cgi\'>$pak</a>)" : "<a href=\'$pak.cgi\'>$service</a>";
}
print "<td align='left' $col width='31%'>$displayname</td> "; my $status = isautorun($pak,$service,$col);