base-files: fix service_running check
authorFlorian Eckert <fe@dev.tdt.de>
Tue, 15 Jun 2021 06:48:18 +0000 (08:48 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Wed, 29 Dec 2021 20:40:40 +0000 (21:40 +0100)
The following command checks if a instance of a service is running.
/etc/init.d/<service> running <instance>

 In the variable `$@`, which is passed to the function
`service_running`, the first argument is always the `instance` which
should be checked. Because all other variables where removed from `$@`
with `shift`.

Before this change the first argument of `$@` was set to the `$service`
Variable. So the function does not work as expected. The `$service`
variable was always the instance which should be checked. This is not
what we want.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Reviewed-by: Sungbo Eo <mans0n@gorani.run>
(cherry picked from commit dd681838d370f1f6f6fa1bf1f22b0414322292f3)

package/base-files/files/etc/rc.common

index f39b69464eac98f92012ecc6f1566531049081b6..5d0d3c23f7478653e6b301900b5c7742f74f1ca3 100755 (executable)
@@ -100,9 +100,9 @@ service_data() {
 }
 
 service_running() {
-       local service="${1:-$(basename $initscript)}"
-       local instance="${2:-*}"
-       procd_running "$service" "$instance" "$@"
+       local instance="${1:-*}"
+
+       procd_running "$(basename $initscript)" "$instance"
 }
 
 ${INIT_TRACE:+set -x}