From: Robin Roevens Date: Tue, 11 Oct 2022 22:01:56 +0000 (+0200) Subject: services.cgi: add restart action and restrict action usage X-Git-Tag: v2.27-core172~211 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f205b54422afa069dd3956ebc4df2efe8600f75;p=ipfire-2.x.git services.cgi: add restart action and restrict action usage * 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 Reviewed-by: Michael Tremer --- diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index e35b04cae3..4b379251ef 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -143,7 +143,7 @@ END my @param=split(/!/, $paramstr); # Make sure action parameter is actually one of the allowed service actions given ($param[1]) { - when ( ['start', 'stop', 'enable', 'disable'] ) { + when ( ['start', 'stop', 'restart', 'enable', 'disable'] ) { # Make sure pak-name and service name don't contain any illegal character if ( $param[0] !~ /[^a-zA-Z_0-9\-]/ && $param[2] !~ /[^a-zA-Z_0-9\-]/ ) { @@ -196,8 +196,6 @@ END my $status = isautorun($pak,$service,$col); print "$status "; - print "$Lang::tr{"; - print "$Lang::tr{ "; my $status = isrunningaddon($pak,$service,$col); $status =~ s/\\[[0-1]\;[0-9]+m//g; @@ -307,7 +305,9 @@ sub isrunningaddon (@) { my $testcmd = @testcmd[0]; if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){ - $status = "$Lang::tr{'running'}"; + $status = "$Lang::tr{ "; + $status .= "$Lang::tr{ "; + $status .= "$Lang::tr{'running'}"; $testcmd =~ s/.* //gi; $testcmd =~ s/[a-z_]//gi; $testcmd =~ s/\[[0-1]\;[0-9]+//gi; @@ -330,7 +330,8 @@ sub isrunningaddon (@) { } $status .="$memory KB"; }else{ - $status = "$Lang::tr{'stopped'}"; + $status = "$Lang::tr{"; + $status .= "$Lang::tr{'stopped'}"; } return $status; }