[OpenWrt-Devel] [PATCH 1/2] base-files: implement generic service_running
Yousong Zhou
yszhou4tech at gmail.com
Tue Jul 23 07:49:25 EDT 2019
On Tue, 23 Jul 2019 at 18:25, Petr Štetiar <ynezz at true.cz> wrote:
>
> DRY is good, otherwise we're going to suffer with a copy&paste disease
> in the init scripts.
>
> Signed-off-by: Petr Štetiar <ynezz at true.cz>
> ---
> package/base-files/files/etc/rc.common | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common
> index 75dbeedf34d4..3bd382ae27ac 100755
> --- a/package/base-files/files/etc/rc.common
> +++ b/package/base-files/files/etc/rc.common
> @@ -95,7 +95,11 @@ service_data() {
> }
>
> service_running() {
> - return 0
> + [ -n "$USE_PROCD" ] || return 0
These xx_service() and service_xxx() functions as commented are for
procd, so no need to check for USE_PROCD here.
yousong
> +
> + local service="${1:-$(basename $initscript)}"
> + local instance="${2:-*}"
> + procd_running "$service" "${instance}" "$@"
> }
>
> ${INIT_TRACE:+set -x}
> @@ -104,6 +108,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")
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list