base-files: implement generic service_running
authorPetr Štetiar <ynezz@true.cz>
Tue, 23 Jul 2019 10:06:29 +0000 (12:06 +0200)
committerPetr Štetiar <ynezz@true.cz>
Sun, 15 Sep 2019 18:58:30 +0000 (20:58 +0200)
DRY is good, otherwise we're going to suffer with a copy&paste disease
in the init scripts.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
package/base-files/files/etc/rc.common

index 75dbeedf34d45937e1fd6acec1fb9c034ec65f8d..37adab0c54e1edcb7a5de32726ff1e42ca6c13c9 100755 (executable)
@@ -95,7 +95,9 @@ service_data() {
 }
 
 service_running() {
-       return 0
+       local service="${1:-$(basename $initscript)}"
+       local instance="${2:-*}"
+       procd_running "$service" "$instance" "$@"
 }
 
 ${INIT_TRACE:+set -x}
@@ -104,6 +106,9 @@ ${INIT_TRACE:+set -x}
 
 [ -n "$USE_PROCD" ] && {
        EXTRA_COMMANDS="${EXTRA_COMMANDS} running trace"
+       EXTRA_HELP="\
+       running Check if service is running
+       "
 
        . $IPKG_INSTROOT/lib/functions/procd.sh
        basescript=$(readlink "$initscript")